本页内容
- 环境要求
- 开始之前
- 安装Apache、MariaDB和PHP
- 创建Concrete5数据库
- 下载Concrete5 CMS
- 为Concrete5 CMS配置Apache
- 访问Concrete5 CMS Web界面
- 使用Let's Encrypt SSL保护Concrete5
- 结语
Concrete5 是一个开源的内容管理系统,用于在互联网上发布内容。它使用 PHP 编写,并以 MariaDB 作为数据库后端。它提供了一个易于使用的构建器,可帮助您通过 Web 浏览器创建页面和内容。它灵活、安全、支持移动端,并基于 Model-View-Controller(模型-视图-控制器)架构。它提供了丰富的功能集,包括 WYSIWYG 内容编辑器、媒体管理器、拖放内容、上下文编辑等等。
在本文中,我们将向您展示如何在 Ubuntu 20.04 服务器上使用 Apache 和 Let's Encrypt SSL 安装 Concrete5 CMS。
环境要求
- 一台运行 Ubuntu 20.04 的服务器。
- 一个指向服务器 IP 的有效域名。
- 您的服务器上已配置 root 密码。
开始之前
首先,您需要将 APT 软件包索引更新到最新版本。您可以使用以下命令进行更新:
apt-get update -y
APT 索引更新完成后,您可以继续进行下一步。
安装Apache、MariaDB和PHP
接下来,您需要在服务器上安装 Apache Web 服务器、MariaDB 数据库服务器、PHP 以及其他 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 文件并设置所需的值:
nano /etc/php/7.4/apache2/php.ini
修改以下行:
file_uploads = On allow_url_fopen = On memory_limit = 256M upload_max_filesize = 64M date.timezone = Asia/Kolkata
完成后,保存并关闭文件,然后重启 Apache 服务以使更改生效:
systemctl restart apache2
完成后,您可以继续进行下一步。
创建Concrete5数据库
接下来,您需要为 Concrete5 创建数据库和用户。首先,使用以下命令登录 MariaDB:
mysql
登录后,使用以下命令创建数据库和用户:
MariaDB [(none)]> CREATE DATABASE concrete5;
MariaDB [(none)]> CREATE USER 'concrete5user'@'localhost' IDENTIFIED BY 'password';
接下来,使用以下命令向 Concrete5 数据库授予所有权限:
MariaDB [(none)]> GRANT ALL ON concrete5.* TO 'concrete5user'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
接下来,使用以下命令刷新权限并退出 MariaDB 控制台:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
完成后,您可以继续进行下一步。
下载Concrete5 CMS
首先,访问 Concrete5 CMS 官网,复制最新版本 Concrete5 的 URL,然后使用以下命令下载:
wget --trust-server-names https://www.concrete5.org/download_file/-/view/115589/ -O concrete5.zip
下载完成后,使用以下命令解压下载的文件:
unzip concrete5.zip
接下来,使用以下命令将解压后的目录移动到 Apache Web 根目录:
mv concrete5-* /var/www/html/concrete5
接下来,使用以下命令为 concrete5 目录设置正确的权限和所有权:
chown -R www-data:www-data /var/www/html/concrete5/
chmod -R 755 /var/www/html/concrete5/
完成后,您可以继续进行下一步。
为Concrete5 CMS配置Apache
接下来,您需要为 Concrete5 CMS 创建一个 Apache 虚拟主机配置文件。您可以使用以下命令创建该文件:
nano /etc/apache2/sites-available/concrete5.conf
添加以下行:
<VirtualHost *:80>
ServerAdmin
[email protected]
DocumentRoot /var/www/html/concrete5/
ServerName concrete5.example.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 虚拟主机和 rewrite 模块:
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 Sat 2021-05-15 15:00:03 UTC; 4s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 15566 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 15585 (apache2)
Tasks: 6 (limit: 2353)
Memory: 13.5M
CGroup: /system.slice/apache2.service
??15585 /usr/sbin/apache2 -k start
??15586 /usr/sbin/apache2 -k start
??15587 /usr/sbin/apache2 -k start
??15588 /usr/sbin/apache2 -k start
??15589 /usr/sbin/apache2 -k start
??15590 /usr/sbin/apache2 -k start
May 15 15:00:03 ubuntu2004 systemd[1]: Starting The Apache HTTP Server...
至此,Apache Web 服务器已配置为托管 Concrete5 CMS。您现在可以继续进行下一步。
访问Concrete5 CMS Web界面
现在,打开您的 Web 浏览器,使用 URL http://concrete5.example.com 访问 Concrete5 CMS Web 界面。您将被重定向到以下页面:

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

确保所有必需的库都已安装,然后点击“继续安装”按钮,您应该会看到以下页面:

在此处填写管理员用户名、密码、数据库用户名、密码以及数据库名称,然后点击“安装 Concrete5”按钮开始安装。安装完成后,您应该会看到以下页面:


现在,点击“编辑您的站点”按钮,您应该会在以下页面上看到 Concrete5 仪表盘:

使用Let's Encrypt SSL保护Concrete5
接下来,建议使用 Let's Encrypt SSL 来保护您的网站。首先,使用以下命令安装 Certbot 客户端:
apt-get install python3-certbot-apache -y
安装完成后,运行以下命令以使用 Let's Encrypt SSL 保护您的网站:
certbot --apache -d concrete5.example.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.example.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.example.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=concrete5.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/concrete5.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/concrete5.example.com/privkey.pem Your cert will expire on 2020-10-23. 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.example.com 安全地访问 Concrete5。
结语
在上面的指南中,您学习了如何在 Ubuntu 20.04 上使用 Apache 和 Let's Encrypt SSL 安装 Concrete5 CMS。现在,您可以使用 Concrete5 CMS 轻松地在互联网上发布您的内容。如果您有任何疑问,请随时向我提问。