如何在 Ubuntu 20.04 上使用 Apache 和免费的 Lets Encrypt SSL 安装 Concrete5 CMS
在此页
- 要求
- 开始
- 安装 Apache、MariaDB 和 PHP
- 创建一个 Concrete5 数据库
- 下载 Concrete5 CMS
- 为 Concrete5 CMS 配置 Apache
- 访问 Concrete5 CMS 网络界面
- 使用 Lets Encrypt SSL 保护 Concrete5
- 结论
Concrete5 是一个开源内容管理系统,用于在互联网上发布内容。它是用 PHP 编写的,使用 MariaDB 作为数据库后端。它提供了一个易于使用的构建器,可帮助您通过 Web 浏览器创建页面和内容。它灵活、安全、移动就绪,并且基于模型-视图-控制器架构。它提供了一组丰富的功能,包括所见即所得的内容编辑器、媒体管理器、拖放内容、上下文编辑等等。
在这篇文章中,我们将向您展示如何在 Ubuntu 20.04 服务器上安装带有 Apache 和 Lets Encrypt SSL 的 Concrete5 CMS。
要求
- 一台运行 Ubuntu 20.04 的服务器。
- 指向服务器 IP 的有效域名。
- 在您的服务器上配置了根密码。
入门
首先,您需要将 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
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 虚拟主机并使用以下命令重写模块:
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 ubunt4 systemd[1]: Starting The Apache HTTP Server...
此时,Apache Web 服务器配置为托管 Concrete5 CMS。您现在可以继续下一步。
访问 Concrete5 CMS Web 界面
现在,打开您的网络浏览器并使用 URL http://concrete5.example.com 访问 Concrete5 CMS 网络界面。您将被重定向到以下页面:

选择您的语言并单击箭头按钮。您应该会看到以下页面:

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

在这里,提供管理员用户名、密码、数据库用户名、密码和数据库名称,然后单击“安装 Concrete5”按钮开始安装。安装完成后,您应该会看到以下页面:


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

使用 Lets Encrypt SSL 保护 Concrete5
接下来,建议使用 Lets Encrypt SSL 来保护您的网站。首先,使用以下命令安装 Certbot 客户端:
apt-get install python3-certbot-apache -y
安装后,运行以下命令以使用 Lets 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):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 键为您的网站安装 Lets 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 安全地访问 Concrete 5。
结论
在上面的指南中,您学习了如何在 Ubuntu 20.04 上安装带有 Apache 和 Lets Encrypt SSL 的 Concrete5 CMS。您现在可以使用 Concrete5 CMS 轻松地在互联网上发布您的内容。如果您有任何问题,请随时问我。