本教程适用于以下操作系统版本
- AlmaLinux 9
- AlmaLinux 8
本页内容
- 准备工作
- 安装 LAMP 服务器
- 配置 MariaDB 数据库
- 下载 Joomla CMS
- 为 Joomla 配置 Apache
- 为 Joomla 配置防火墙
- 访问 Joomla Web 安装向导
- 使用 Let's Encrypt SSL 保护 Joomla CMS
- 结论
Joomla 是一款免费、开源且最受欢迎的内容管理系统之一。它使用 PHP 编写,可用于在无需任何编程知识的情况下创建网站和博客。它提供免费和付费的插件与主题,帮助你扩展网站功能。它提供直观的控制面板,可通过 Web 浏览器管理网站。Joomla 提供了许多非常实用的功能,包括多语言支持、媒体管理器、SEO、集成帮助系统、联系人管理等等。
在本教程中,你将学习如何在 Alma Linux 8 上使用 Apache 和 Let's Encrypt SSL 安装 Joomla CMS。
准备工作
- 一台运行 Alma Linux 8 的服务器。
- 一个已解析到服务器 IP 的有效域名。
- 服务器上已配置 root 密码。
安装 LAMP 服务器
Joomla 运行在 Web 服务器上,使用 PHP 编写,并以 MariaDB 作为数据库后端。因此,你需要在系统上安装 LAMP 服务器。可以使用以下命令安装:
dnf install httpd @mariadb php php-curl php-xml php-zip php-mysqlnd php-intl php-gd php-json php-ldap php-mbstring php-opcache unzip curl wget -y
安装完成后,编辑 PHP 配置文件并修改默认设置:
nano /etc/php.ini
修改以下各行:
memory_limit = 256M output_buffering = Off max_execution_time = 300 date.timezone = UTC
保存并关闭文件,然后启动 Apache 服务,并设置为系统重启后自动启动:
systemctl start httpd mariadb
systemctl enable httpd mariadb
配置 MariaDB 数据库
接下来,你需要为 Joomla CMS 创建数据库和用户。首先,使用以下命令连接到 MariaDB shell:
mysql
登录后,使用以下命令创建数据库和用户:
MariaDB [(none)]> CREATE DATABASE joomla;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON joomla.* TO 'joomla'@'localhost' IDENTIFIED BY "securepassword";
接下来,重新加载权限以使更改生效:
MariaDB [(none)]> FLUSH PRIVILEGES;
接下来,使用以下命令退出 MariaDB shell:
MariaDB [(none)]> EXIT;
完成后,即可继续下一步。
下载 Joomla CMS
在撰写本教程时,最新可用版本是 Joomla 4.1.2。你可以使用以下命令从其官方下载页面下载:
wget https://downloads.joomla.org/cms/joomla4/4-1-2/Joomla_4-1-2-Stable-Full_Package.zip?format=zip -O joomla.zip
下载完成后,使用以下命令将下载的文件解压到 Apache Web 根目录:
unzip joomla.zip -d /var/www/html/joomla
接下来,更改 Joomla 目录的所有者和权限:
chown -R apache:apache /var/www/html/joomla/
chmod -R 775 /var/www/html/joomla/
完成后,即可继续下一步。
为 Joomla 配置 Apache
接下来,你需要为 Joomla 创建 Apache 虚拟主机配置文件。可以使用以下命令创建:
nano /etc/httpd/conf.d/joomla.conf
添加以下代码:
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "/var/www/html/joomla" ServerName joomla.example.com ErrorLog "/var/log/httpd/example.com-error_log" CustomLog "/var/log/httpd/example.com-access_log" combined <Directory "/var/www/html/joomla"> DirectoryIndex index.html index.php Options FollowSymLinks AllowOverride All Require all granted </Directory> </VirtualHost>
保存并关闭文件,然后重启 Apache 服务以使配置更改生效:
systemctl restart httpd
现在可以使用以下命令检查 Apache Web 服务器的状态:
systemctl status httpd
你将看到如下输出:
? httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/httpd.service.d
??php-fpm.conf
Active: active (running) since Fri 2022-04-15 08:52:59 UTC; 3s ago
Docs: man:httpd.service(8)
Main PID: 4749 (httpd)
Status: "Started, listening on: port 80"
Tasks: 213 (limit: 11412)
Memory: 24.3M
CGroup: /system.slice/httpd.service
??4749 /usr/sbin/httpd -DFOREGROUND
??4751 /usr/sbin/httpd -DFOREGROUND
??4752 /usr/sbin/httpd -DFOREGROUND
??4753 /usr/sbin/httpd -DFOREGROUND
??4754 /usr/sbin/httpd -DFOREGROUND
Apr 15 08:52:59 linux systemd[1]: httpd.service: Succeeded.
Apr 15 08:52:59 linux systemd[1]: Stopped The Apache HTTP Server.
Apr 15 08:52:59 linux systemd[1]: Starting The Apache HTTP Server...
完成 Apache 配置后,即可继续下一步。
为 Joomla 配置防火墙
接下来,你需要允许 HTTP 和 HTTPS 服务通过防火墙。可以使用以下命令放行:
firewall-cmd --add-service=http --zone=public --permanent
firewall-cmd --add-service=https --zone=public --permanent
接下来,重新加载 firewalld 以使更改生效:
firewall-cmd --reload
访问 Joomla Web 安装向导
现在,打开 Web 浏览器,通过 URL http://joomla.example.com 访问 Joomla 安装页面。你将被重定向到以下界面:

选择语言,填写网站名称,然后点击 Setup Login Data。你将看到管理员配置界面:

填写管理员用户名、密码,然后点击 Setup Database Connection。你将看到以下界面:

填写数据库名、用户名和密码,然后点击 Install Joomla 按钮。Joomla 安装完成后,你将看到以下界面:

点击 Open Administrator 按钮。你将看到 Joomla 登录界面:

填写管理员用户名、密码,然后点击 Log in 按钮。你将在以下界面看到 Joomla 仪表板:

使用 Let's Encrypt SSL 保护 Joomla CMS
接下来,你需要安装 Certbot 客户端,以便为网站安装 Let's Encrypt SSL。可以使用以下命令安装:
dnf install epel-release -y
dnf install certbot python3-certbot-apache
接下来,使用以下命令为你的域名获取并安装 SSL 证书:
certbot --apache -d joomla.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): [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. 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 Account registered. Requesting a certificate for joomla.example.com Performing the following challenges: http-01 challenge for joomla.example.com Waiting for verification... Cleaning up challenges Deploying Certificate to VirtualHost /etc/httpd/conf.d/joomla.conf Redirecting all traffic on port 80 to ssl in /etc/httpd/conf.d/joomla.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://joomla.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Subscribe to the EFF mailing list (email: [email protected] ). IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/joomla.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/joomla.example.com/privkey.pem Your certificate will expire on 2022-07-09. 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
结论
恭喜!你已成功在 Alma Linux 8 上使用 Apache 和 Let's Encrypt SSL 安装了 Joomla CMS。借助强大的 Joomla CMS,你现在无需任何编程或代码知识即可构建自己的网站。如有任何疑问,欢迎随时提出。