如何使用 Apache 安装 Automad CMS 并让我们在 Debian 10 上加密
在此页
- 要求
- 开始
- 安装 Apache 和 PHP
- 安装 Automad
- 为 Automad 配置 Apache
- 访问 Automad
- 使用 Lets Encrypt 保护 Automad
Automad 是一个用 PHP 语言编写的免费、开源和扁平化的内容管理系统。它速度快、反应灵敏,并提供其他基于 PHP 的 CMS 可能不具备的功能。 Automad 使用文本文件而不是数据库来存储其内容。 Automad 提供了一个基于网络的界面,用于管理站点、系统设置、上传图像和撰写博客文章。它附带一个内置的 Markdown 编辑器和一键式更新程序,让您的 Automad 保持最新。
在本教程中,我们将向您展示如何使用 Apache Web 服务器在 Debian 10 上安装 Automad CMS。
要求
- 运行 Debian 10 的服务器。
- 已为您的服务器设置根密码。
入门
在开始之前,您需要使用最新版本更新您的系统。您可以通过运行以下命令来执行此操作:
apt-get update -y
apt-get upgrade -y
服务器更新后,重新启动服务器以应用更改。
安装 Apache 和 PHP
Automad 基于 PHP 并在 Web 服务器上运行。因此,您需要在服务器上安装 Apache、PHP 和其他所需的模块。您可以通过运行以下命令来安装所有这些:
apt-get install apache2 php libapache2-mod-php php-zip php-curl php-mbstring php-gd php-xml php-xmlrpc php-soap unzip -y
安装所有软件包后,启动 Apache Web 服务器并使用以下命令使其在系统重启时启动:
systemctl start apache2
systemctl enable apache2
完成后,您可以继续下一步。
安装Automad
首先,您需要从 Bitbucket 存储库下载最新版本的 Automad。您可以使用以下命令下载它:
wget https://bitbucket.org/marcantondahmen/automad/get/default.zip
下载完成后,使用以下命令解压缩下载的文件:
unzip default.zip
接下来,使用以下命令将提取的目录移动到 Apache Web 根目录:
mv marcantondahmen-automad-c241e88edc3c /var/www/html/automad
接下来,将 automad 目录的所有权更改为 www-data 并使用以下命令授予适当的权限:
chown -R www-data:www-data /var/www/html/automad
chmod -R 755 /var/www/html/automad
完成后,您可以继续下一步。
为 Automad 配置 Apache
接下来,您需要为服务器 Automad 创建一个 Apache 虚拟主机配置文件。您可以使用以下命令创建它:
nano /etc/apache2/sites-available/automad.conf
添加以下内容:
<VirtualHost *:80>
ServerAdmin
DocumentRoot /var/www/html/automad
ServerName example.com
<Directory /var/www/html/automad>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/automadcms_error.log
CustomLog ${APACHE_LOG_DIR}/automadcms_access.log combined
</VirtualHost>
完成后保存并关闭文件。然后,使用以下命令检查 Apache 是否存在任何语法错误:
apachectl configtest
如果一切正常,您应该得到以下输出:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK
接下来,使用以下命令启用 Apache 虚拟主机和重写模块:
a2ensite automad
a2enmod rewrite
最后,重新启动 Apache Web 服务器以应用配置更改:
systemctl restart apache2
完成后,您可以继续下一步。
访问自动化
Automad 现已安装和配置,是时候访问 Automad Web 界面了。
打开 Web 浏览器并输入 URL http://example.com。您将被重定向到以下屏幕中的 Automad 站点:

要创建 Automad 帐户,请打开您的 Web 浏览器并访问 URL http://example.com/dashboard。您将被重定向到以下页面:


现在,提供您想要的用户名和密码,然后单击“下载帐户文件”按钮下载用户注册表并将其复制到配置目录中:
mv config.php /var/www/html/automad/config/
接下来,使用以下命令为 config.php 文件授予适当的权限:
chown -R www-data:www-data /var/www/html/automad/config/config.php
现在,打开您的 Web 浏览器并输入 URL http://example.com/dashboard。您应该会看到 Automad 登录页面:

现在,提供您的用户名和密码,然后单击“登录”按钮。您应该在以下页面中看到 Automad CMS 默认仪表板:

使用 Lets Encrypt 保护 Automad
首先,您需要安装 Certbot 工具来为您的网站下载并安装 Lets Encrypt 免费 SSL。
首先,使用以下命令添加 Certbot 存储库:
apt-get install software-properties-common
add-apt-repository ppa:certbot/certbot
接下来,更新存储库并使用以下命令安装 Certbot:
apt-get update -y
apt-get install certbot python-certbot-apache -y
安装后,您需要在 letsencrypt 目录中创建一个 .well-known 目录。您可以使用以下命令创建它:
mkdir -p /var/lib/letsencrypt/.well-known
接下来,您需要为 letsencrypt 目录授予适当的权限。您可以使用以下命令执行此操作:
chgrp www-data /var/lib/letsencrypt
chmod g+s /var/lib/letsencrypt
接下来,使用以下命令创建一个 well-known.conf 文件:
nano /etc/apache2/conf-available/well-known.conf
添加以下行:
Alias /.well-known/acme-challenge/ "/var/lib/letsencrypt/.well-known/acme-challenge/"
<Directory "/var/lib/letsencrypt/">
AllowOverride None
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Require method GET POST OPTIONS
</Directory>
保存并关闭文件。然后,使用以下命令启用所需的模块:
a2enmod ssl
a2enmod http2
a2enmod headers
a2enconf well-known
接下来,重新启动 Apache 服务以应用所有配置更改:
systemctl restart apache2
现在,通过运行以下命令为您的域 example.com 安装 Lets Encrypt 免费 SSL:
certbot --apache -d example.com
首先,您需要提供一个有效的电子邮件地址并同意如下所示的服务条款:
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/example.com-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-available/example.com-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/example.com-le-ssl.conf
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
接下来,选择选项 2 为您的域下载并安装免费的 SSL 证书。安装成功完成后。您应该得到以下输出:
Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/example.com.conf to ssl vhost in /etc/apache2/sites-available/
example.com-le-ssl.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://example.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/example.com/privkey.pem
Your cert will expire on 2019-10-22. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
您的 Automad CMS 现在受到 Lets Encrypt 免费 SSL 的保护。您可以通过访问 URL https://example.com 来访问它。