本教程适用于以下操作系统版本
- Ubuntu 22.04 (Jammy Jellyfish)
- Ubuntu 20.04 (Focal Fossa)
- Ubuntu 18.04 (Bionic Beaver)
本页内容
- 先决条件
- 安装 Apache、MariaDB 和 PHP
- 创建 Fork CMS 数据库
- 安装 Fork CMS
- 为 Fork CMS 创建 Apache 虚拟主机
- 访问 Fork CMS Web 界面
- 使用 Let's Encrypt SSL 保护 ForkCMS
- 结论
Fork 是一款面向初学者和专业人士的开源内容管理系统(CMS)。它旨在创建一个用户友好的环境,用于构建、监控和更新您的网站。它最初是作为一款 CMS 推出的,提供博客、页面和用户等额外模块。其强大的应用和主题可帮助您按需自定义网站。它拥有用户友好的界面,可帮助用户快速、轻松地创建网站。
本教程将向您展示如何在 Ubuntu 22.04 上使用 Apache 和 Let's Encrypt SSL 安装 Fork CMS。
先决条件
- 运行 Ubuntu 22.04 的服务器。
- 一个指向您服务器 IP 的有效域名。
- 服务器上已配置 root 密码。
安装 Apache、MariaDB 和 PHP
首先,使用以下命令安装 Apache Web 服务器和 MariaDB 服务器:
apt-get install apache2 mariadb-server -y
接下来,您需要在服务器上安装 PHP 7.4 版本及其他扩展。但是,PHP 7.4 版本未包含在 Ubuntu 默认软件源中。因此,您需要将 Ondrej PHP 软件源添加到服务器。您可以使用以下命令添加:
apt install software-properties-common
add-apt-repository ppa:ondrej/php -y
添加 PHP 软件源后,您可以使用以下命令安装 PHP 及其他所需扩展:
apt-get install php7.4 libapache2-mod-php7.4 php7.4-xml php7.4-cli php7.4-zip php7.4-common php7.4-sqlite3 php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-mysql php7.4-gd wget unzip -y
安装完所有这些软件包后,编辑 PHP 配置文件并更改默认设置:
nano /etc/php/7.4/apache2/php.ini
根据您的需求更改以下设置:
memory_limit = 256M upload_max_filesize = 100M max_execution_time = 360 file_uploads = On date.timezone = UTC
保存并关闭文件,然后重启 Apache 服务以使配置更改生效:
systemctl restart apache2
创建 Fork CMS 数据库
首先,您需要加固 MariaDB 并设置 MariaDB root 密码。您可以运行以下脚本来加固 MariaDB 安装:
mysql_secure_installation
该脚本将设置 root 密码、删除匿名用户、禁止 root 远程登录并移除测试数据库,如下所示:
Set root password? [Y/n] n Remove anonymous users? [Y/n] y Disallow root login remotely? [Y/n] y Remove test database and access to it? [Y/n] y Reload privilege tables now? [Y/n] y Once MariaDB is secured, log in to MariaDB shell:
接下来,使用以下命令登录 MariaDB shell:
mysql -u root -p
输入您的 root 密码,然后为 Fork CMS 创建数据库和用户:
MariaDB [(none)]> CREATE DATABASE forkdb;
MariaDB [(none)]> CREATE USER 'forkuser'@'localhost' IDENTIFIED BY 'password';
接下来,使用以下命令为 Fork CMS 数据库授予权限:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON forkdb.* TO 'forkuser'@'localhost';
接下来,运行 FLUSH PRIVILEGES 命令,以便 MariaDB 重新加载权限表:
MariaDB [(none)]> FLUSH PRIVILEGES;
最后,使用以下命令退出 MariaDB shell:
MariaDB [(none)]> EXIT;
安装 Fork CMS
首先,您需要在系统中安装 Composer。您可以使用以下命令安装:
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
您将看到以下输出:
All settings correct for using Composer Downloading... Composer (version 2.4.4) successfully installed to: /usr/local/bin/composer Use it: php /usr/local/bin/composer
接下来,进入 Apache Web 根目录,并使用 Composer 下载 Fork CMS:
cd /var/www/html/
composer create-project forkcms/forkcms
接下来,为 Fork CMS 目录设置正确的权限和归属:
chown -R www-data:www-data /var/www/html/forkcms
chmod -R 775 /var/www/html/forkcms
完成后,您可以继续下一步。
为 Fork CMS 创建 Apache 虚拟主机
接下来,您需要创建一个 Apache 虚拟主机配置文件,以便通过互联网提供 Fork CMS 服务。您可以使用以下命令创建:
nano /etc/apache2/sites-available/forkcms.conf
添加以下行:
<VirtualHost *:80>
ServerAdmin
[email protected]
DocumentRoot /var/www/html/forkcms
ServerName forkcms.example.com
<Directory /var/www/html/forkcms/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
保存并关闭文件,然后使用以下命令激活 Fork CMS 并启用 Apache rewrite 模块:
a2ensite forkcms.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 Tue 2022-12-13 05:35:24 UTC; 1s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 94668 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 94672 (apache2)
Tasks: 6 (limit: 2238)
Memory: 13.4M
CPU: 45ms
CGroup: /system.slice/apache2.service
??94672 /usr/sbin/apache2 -k start
??94673 /usr/sbin/apache2 -k start
??94674 /usr/sbin/apache2 -k start
??94675 /usr/sbin/apache2 -k start
??94676 /usr/sbin/apache2 -k start
??94677 /usr/sbin/apache2 -k start
Dec 13 05:35:24 ubuntu2204 systemd[1]: apache2.service: Deactivated successfully.
Dec 13 05:35:24 ubuntu2204 systemd[1]: Stopped The Apache HTTP Server.
Dec 13 05:35:24 ubuntu2204 systemd[1]: Starting The Apache HTTP Server...
完成后,您可以继续下一步。
访问 Fork CMS Web 界面
现在,打开您的 Web 浏览器并输入 URL http://forkcms.example.com/install/2。您将被重定向到以下页面:

在此处,按需选择语言,然后点击“Next”按钮。您将看到以下页面:


在此处,选择您要安装的模块,然后点击“Next”按钮。您将看到以下页面:

在此处,填写您的数据库详细信息,然后点击“Next”按钮。您将看到以下页面:

在此处,填写您的管理员邮箱地址、用户名和密码,然后点击“Finish Installation”按钮。您将看到以下页面:

现在,点击“Log In To Fork CMS”按钮。您将在以下页面看到 Fork CMS 登录界面:

现在,填写您的管理员用户名和密码,然后点击“Log In”按钮。您将被重定向到 Fork CMS 控制面板,如下图所示:

使用 Let's Encrypt SSL 保护 ForkCMS
要在 ForkCMS 网站上安装 Let's Encrypt SSL,您需要在服务器上安装 certbot 软件包。
首先,使用以下命令安装 Snap 软件包管理器:
apt install snapd
接下来,将 Snap 软件包更新到最新版本:
snap install core
snap refresh core
接下来,使用以下命令安装 certbot 软件包:
snap install --classic certbot
接下来,为 Certbot 二进制文件创建指向系统位置的符号链接:
ln -s /snap/bin/certbot /usr/bin/certbot
接下来,运行以下命令来下载并安装 Let's Encrypt SSL 证书:
certbot --apache -d forkcms.example.com
系统将要求您提供邮箱地址并接受服务条款:
Saving debug log to /var/log/letsencrypt/letsencrypt.log 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.3-September-21-2022.pdf. You must agree in order to register with the ACME server. Do you agree? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you be willing, once your first certificate is successfully issued, 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
输入 Y 并按 Enter 键,以下载并为您的域名安装 SSL 证书:
Account registered. Requesting a certificate for forkcms.example.com Successfully received certificate. Certificate is saved at: /etc/letsencrypt/live/forkcms.example.com/fullchain.pem Key is saved at: /etc/letsencrypt/live/forkcms.example.com/privkey.pem This certificate expires on 2023-02-28. These files will be updated when the certificate renews. Certbot has set up a scheduled task to automatically renew this certificate in the background. Deploying certificate Successfully deployed certificate for forkcms.example.com to /etc/nginx/conf.d/mastodon.conf Congratulations! You have successfully enabled HTTPS on https://forkcms.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
结论
在本文中,我们介绍了如何在 Ubuntu 22.04 服务器上使用 Apache 和 Let's Encrypt SSL 安装 Fork CMS。您现在可以通过 Fork CMS 直观的 Web 界面构建、监控和更新您的网站。如果您有任何问题,欢迎随时向我提问。