使用 Nginx 安装 Automad CMS 并在 Ubuntu 18.04 上加密 SSL使用 Nginx 安装 Automad CMS 并在 Ubuntu 18.04 上加密 SSL使用 Nginx 安装 Automad CMS 并在 Ubuntu 18.04 上加密 SSL使用 Nginx 安装 Automad CMS 并在 Ubuntu 18.04 上加密 SSL
  • 文章
  • 正则表达式
    • 工具
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容
发表 admin at 2025年2月28日
类别
  • 未分类
标签

使用 Nginx 安装 Automad CMS 并在 Ubuntu 18.04 上加密 SSL

在此页

  1. 要求
  2. 先决条件
  3. 初始步骤
  4. 第 1 步 - 安装 PHP 和必要的 PHP 扩展
  5. 第 2 步 - 安装 acme.sh 客户端并获取 Lets Encrypt 证书(可选)
  6. 第 3 步 - 安装和配置 NGINX
  7. 第 4 步 - 安装 Automad CMS
  8. 第 5 步 - 完成 Automad 安装
  9. 链接

Automad 是一个开源的基于文件的内容管理系统 (CMS) 和一个用 PHP 编写的模板引擎。所有内容都存储在人类可读的文本文件中,而不是数据库中。因此,Automad 站点是完全可移植的,易于安装,并且可以使用 Git 或 Mercurial 进行版本控制。尽管如此,它仍提供搜索和标记等数据库功能。内置的模板引擎甚至可以让没有经验的开发人员和设计人员创建漂亮的主题和模板。在本教程中,我们将使用 NGINX 作为网络服务器,在 Ubuntu 18.04 LTS 系统上安装和设置 Automad CMS。

要求

安装和运行 Automad CMS 的要求如下:

  • PHP 5.4 或更高版本。
  • 网络服务器软件,例如 Nginx 或 Apache。

先决条件

  • Ubuntu 18.04 LTS 操作系统。
  • 具有 sudo 权限的非根用户。

初始步骤

检查你的 Ubuntu 版本:

lsb_release -ds
# Ubuntu 18.04.2 LTS

设置时区:

sudo dpkg-reconfigure tzdata

更新您的操作系统包(软件)。这是必不可少的第一步,因为它确保您拥有操作系统默认软件包的最新更新和安全修复程序:

sudo apt update && sudo apt upgrade -y

安装 Ubuntu 操作系统基本管理所需的一些基本软件包:

sudo apt install -y curl wget vim git unzip socat bash-completion apt-transport-https

第 1 步 - 安装 PHP 和必要的 PHP 扩展

安装 PHP 以及所需的 PHP 扩展:

sudo apt install -y php7.2 php7.2-cli php7.2-fpm php7.2-common php7.2-mbstring php7.2-xmlrpc php7.2-soap php7.2-gd php7.2-xml php7.2-curl php7.2-zip

要显示在模块中编译的 PHP,您可以运行:

php -m

ctype
curl
exif
fileinfo
. . .
. . .

检查版本:

php --version

# PHP 7.2.19-0ubuntu0.18.04.1 (cli) (built: Jun 4 2019 14:48:12) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.2.19-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies

PHP-FPM服务在Ubuntu 18.04系统重启时自动启动启用,无需手动启动启用。我们可以继续下一步。

第 2 步 - 安装 acme.sh 客户端并获取 Lets Encrypt 证书(可选)

使用 HTTPS 保护您的论坛不是必需的,但这是保护您的网站流量的一个好习惯。要从 Lets Encrypt 获取 TLS 证书,我们将使用 acme.sh 客户端。 Acme.sh 是一个简单的 UNIX shell 软件,用于零依赖地从 Lets Encrypt 获取 TLS 证书。

下载并安装 acme.sh:

sudo su - root
git clone https://github.com/Neilpang/acme.sh.git
cd acme.sh
./acme.sh --install --accountemail
source ~/.bashrc
cd ~

检查 acme.sh 版本:

acme.sh --version
# v2.8.0

为您的域/主机名获取 RSA 和 ECC/ECDSA 证书:<br>

# RSA 2048
acme.sh --issue --standalone -d example.com --keylength 2048
# ECDSA
acme.sh --issue --standalone -d example.com --keylength ec-256

如果你想要假证书进行测试,你可以在上面的命令中添加 --staging 标志。

运行上述命令后,您的证书 和密钥 将位于:

  • 对于 RSA:/home/username/example.com 目录。
  • 对于 ECC/ECDSA:/home/username/example.com_ecc 目录。

要列出您颁发的证书,您可以运行:

acme.sh --list

创建一个目录来存储您的证书。我们将使用 /etc/letsencrypt 目录。

mkdir -p /etc/letsecnrypt/example.com
sudo mkdir -p /etc/letsencrypt/example.com_ecc

安装/复制证书到 /etc/letsencrypt 目录。

# RSA
acme.sh --install-cert -d example.com --cert-file /etc/letsencrypt/example.com/cert.pem --key-file /etc/letsencrypt/example.com/private.key --fullchain-file /etc/letsencrypt/example.com/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"
# ECC/ECDSA
acme.sh --install-cert -d example.com --ecc --cert-file /etc/letsencrypt/example.com_ecc/cert.pem --key-file /etc/letsencrypt/example.com_ecc/private.key --fullchain-file /etc/letsencrypt/example.com_ecc/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"

所有证书将每 60 天自动更新一次。

获得证书后,从 root 用户退出并返回到普通 sudo 用户:

exit

第 3 步 - 安装和配置 NGINX

从 Ubuntu 存储库下载并安装 NGINX:

sudo apt install -y nginx

检查 NGINX 版本:

sudo nginx -v
# nginx version: nginx/1.14.0 (Ubuntu)

运行 sudo vim /etc/nginx/sites-available/automad.conf 并使用以下配置填充文件:

server {

  listen [::]:443 ssl http2;
listen 443 ssl http2;
listen [::]:80;
listen 80;
# RSA
ssl_certificate /etc/letsencrypt/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com/private.key;
# ECC
ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com_ecc/private.key;
server_name example.com; root /var/www/automad; index index.php index.html; client_max_body_size 100M; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { fastcgi_index index.php; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }

通过将文件链接到 sites-enabled 目录来激活新的 automad.conf 配置:

sudo ln -s /etc/nginx/sites-available/automad.conf /etc/nginx/sites-enabled/

检查 NGINX 配置是否存在语法错误:

sudo nginx -t

重新加载 Nginx:

sudo systemctl reload nginx.service

第 4 步 - 安装 Automad CMS

为Automad创建文档根目录:

sudo mkdir -p /var/www/automad

导航到文档根目录:

cd /var/www/automad

使用 curl 下载最新版本的 Automad CMS。如果有更新的版本,不要忘记提高版本号:

sudo curl -O -J -L https://automad.org/download

解压缩 zip 存档:

sudo unzip marcantondahmen-automad-6fff2a0456dc.zip

将所有 Automad 文件移动到文档根目录并删除下载的 zip 存档:

sudo mv marcantondahmen-automad-6fff2a0456dc/* . && sudo mv marcantondahmen-automad-6fff2a0456dc/.* .
sudo rm marcantondahmen-automad-6fff2a0456dc.zip
sudo rmdir marcantondahmen-automad-6fff2a0456dc

将 /var/www/automad 目录的所有权更改为 www-data:

sudo chown -R www-data:www-data /var/www/automad

第 5 步 - 完成 Automad 安装

作为最后一步,创建一个用户帐户以使用称为仪表板的基于浏览器的用户界面。因此导航到 https://example.com/dashboard 并按照说明进行操作。

在使用 Automad 仪表板之前,您需要创建一个帐户:

使用表单创建用户帐户并将生成的文件下载到您的计算机。之后,您需要将下载的文件移动到 Automad 安装目录中的 \/config\ 目录。

之后,您可以登录到 Automad 仪表板:

最后会显示Automad管理界面:

就是这样。自动安装完成。

链接

  • https://automad.org/
  • https://bitbucket.org/marcantondahmen/automad/

©2015-2025 艾丽卡 support@alaica.com