本教程适用于以下操作系统版本
- Debian 11 (Bullseye)
- Debian 9 (Stretch)
本页内容
- 先决条件
- 安装 Apache、MariaDB 和 PHP
- 为 Concrete5 创建数据库
- 安装 Concrete5 CMS
- 创建 Apache 虚拟主机配置文件
- 访问 Concrete5 CMS
- 使用 Let's Encrypt SSL 保护 Concrete5
- 结论
Concrete5 是一个用于发布互联网内容的免费开源内容管理系统。它专为计算机技能有限的初学者用户设计,允许他们直接从 Web 浏览器编辑网站。它简单、轻量、易于使用,并使用 PHP 编写。它附带大量实用功能,包括直观的 Web 界面、SEO 友好、社交媒体、移动端优化、可扩展、集成报告等。
本文将向您展示如何在 Debian 11 上使用 Apache 和 Let's Encrypt SSL 安装 Concrete5 CMS。
先决条件
- 一台运行 Debian 11 的服务器。
- 一个已解析到您服务器 IP 的有效域名。
- 服务器上已配置 root 密码。
安装 Apache、MariaDB 和 PHP
首先,您需要在服务器上安装 Apache Web 服务器、MariaDB 数据库服务器、PHP 以及其他必需的扩展。您可以通过运行以下命令来安装它们:
apt-get install apache2 mariadb-server php libapache2-mod-php libapache2-mod-php php-common php-mbstring php-xmlrpc php-soap php-gd php-xml php-intl php-mysql php-cli php-ldap php-zip php-curl -y
所有软件包安装完成后,编辑 php.ini 文件并调整一些 PHP 设置:
nano /etc/php/7.3/apache2/php.ini
修改以下行:
file_uploads = On allow_url_fopen = On memory_limit = 256M upload_max_filesize = 64M date.timezone = UTC
完成后保存并关闭文件,然后重新启动 Apache 服务以使更改生效:
systemctl restart apache2
为 Concrete5 创建数据库
Concrete5 使用 MariaDB 或 MySQL 作为数据库后端。因此您需要为 Concrete5 创建一个数据库和用户。
首先,使用以下命令登录 MariaDB:
mysql
登录后,使用以下命令创建数据库和用户:
MariaDB [(none)]> CREATE DATABASE concrete5;
MariaDB [(none)]> CREATE USER 'concrete5'@'localhost' IDENTIFIED BY 'password';
接下来,使用以下命令授予 Concrete5 数据库所有权限:
MariaDB [(none)]> GRANT ALL ON concrete5.* TO 'concrete5'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
接下来,使用以下命令刷新权限并退出 MariaDB 控制台:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
安装 Concrete5 CMS
接下来,访问 Concrete5 CMS 下载页面,复制最新版 Concrete5 的 URL,并运行以下命令将其下载到您的系统:
wget https://www.concretecms.org/application/files/3916/3649/1545/concrete-cms-9.0.1.zip
下载完成后,使用以下命令解压下载的文件:
unzip concrete-cms-9.0.1.zip
接下来,将解压后的目录移动到 Apache Web 根目录:
mv concrete-cms-9.0.1 /var/www/html/concrete5
接下来,使用以下命令更改 concrete5 目录的所有权和权限:
chown -R www-data:www-data /var/www/html/concrete5/
chmod -R 755 /var/www/html/concrete5/
完成后,您可以继续下一步。
创建 Apache 虚拟主机配置文件
接下来,您需要为 Concrete5 CMS 创建一个 Apache 虚拟主机配置文件。您可以使用以下命令创建:
nano /etc/apache2/sites-available/concrete5.conf
添加以下行:
<VirtualHost *:80>
ServerAdmin
[email protected]
DocumentRoot /var/www/html/concrete5
ServerName concrete5.yourdomain.com
<Directory /var/www/html/concrete5>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
保存并关闭文件,然后使用以下命令启用 Apache 虚拟主机和重写模块:
a2ensite concrete5.conf
a2enmod rewrite
最后,使用以下命令重新启动 Apache 服务:
systemctl restart apache2
您也可以使用以下命令检查 Apache 服务状态:
systemctl status apache2
您应该看到以下输出:
? apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-12-10 14:29:49 UTC; 5s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 16050 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 16054 (apache2)
Tasks: 6 (limit: 4701)
Memory: 15.4M
CGroup: /system.slice/apache2.service
??16054 /usr/sbin/apache2 -k start
??16055 /usr/sbin/apache2 -k start
??16056 /usr/sbin/apache2 -k start
??16057 /usr/sbin/apache2 -k start
??16058 /usr/sbin/apache2 -k start
??16059 /usr/sbin/apache2 -k start
Dec 10 14:29:49 debian11 systemd[1]: Starting The Apache HTTP Server...
完成后,您可以继续下一步。
访问 Concrete5 CMS
现在,打开您的 Web 浏览器,使用 URL http://concrete5.yourdomain.com 访问 Concrete5 CMS。您将被重定向到以下页面:

选择您的语言,然后点击 > 按钮。您应该看到以下页面:

确保所有 PHP 扩展均已安装,然后点击 Continue to Installation 按钮。您应该看到以下页面:


输入您的管理员用户名、密码、数据库名称、数据库用户名、密码,然后点击 Install Concrete5 按钮。安装完成后,您应该看到以下页面:

点击 Edit Your Site。您应该看到以下页面中的 Concrete5 仪表盘:

使用 Let's Encrypt SSL 保护 Concrete5
如果您想使用 Let's Encrypt SSL 保护您的网站,则需要安装 Certbot 客户端软件包,以安装和管理您网站的 Let's Encrypt SSL。
您可以通过运行以下命令来安装它:
apt-get install python3-certbot-apache -y
Certbot 软件包安装完成后,运行以下命令为您的网站下载并安装 Let's Encrypt SSL。
certbot --apache -d concrete5.yourdomain.com
系统将要求您提供电子邮件并接受服务条款,如下所示:
Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator standalone, Installer None Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): [email protected] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 Plugins selected: Authenticator apache, Installer apache Obtaining a new certificate Performing the following challenges: http-01 challenge for concrete5.yourdomain.com Enabled Apache rewrite module Waiting for verification... Cleaning up challenges Created an SSL vhost at /etc/apache2/sites-available/concrete5-le-ssl.conf Enabled Apache socache_shmcb module Enabled Apache ssl module Deploying Certificate to VirtualHost /etc/apache2/sites-available/concrete5-le-ssl.conf Enabling available site: /etc/apache2/sites-available/concrete5-le-ssl.conf
接下来,选择是否将 HTTP 流量重定向到 HTTPS,如下所示:
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 并按 Enter 键,为您的网站安装 Let's Encrypt SSL:
Enabled Apache rewrite module Redirecting vhost in /etc/apache2/sites-enabled/concrete5.conf to ssl vhost in /etc/apache2/sites-available/concrete5-le-ssl.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://concrete5.yourdomain.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=open.yourdomain.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/concrete5.yourdomain.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/open.yourdomain.com/privkey.pem Your cert will expire on 2022-03-11. 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" - 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
现在,您可以使用 URL https://concrete5.yourdomain.com 安全地访问您的网站。
结论
恭喜!您已成功在 Debian 11 上使用 Apache 和 Let's Encrypt SSL 安装了 Concrete5 CMS。现在您可以从 Web 浏览器轻松创建和编辑您的网站。如果您有任何问题,欢迎随时提问。