如何在 Alma Linux 8 上使用 Apache 和免费的 Lets Encrypt SSL 安装 Joomla
在此页
- 先决条件
- 安装 LAMP 服务器
- 配置 MariaDB 数据库
- 下载 Joomla CMS
- 为 Joomla 配置 Apache
- 为 Joomla 配置防火墙
- 访问 Joomla Web 安装向导
- 使用 Lets Encrypt SSL 保护 Joomla CMS
- 结论
Joomla 是一个免费的开源软件,也是最流行的内容管理系统之一。它是用 PHP 编写的,用于在没有任何编程知识的情况下创建网站和博客。它提供免费和付费的插件和主题,可帮助您扩展网站功能。它提供了一个主动控制面板,用于从 Web 浏览器管理网站。 Joomla 提供了非常有用的功能,包括多语言支持、媒体管理器、SEO、集成帮助系统、联系人管理等等。
在本教程中,您将学习如何在 Alma Linux 8 上使用 Apache 和 Lets Encrypt SSL 安装 Joomla CMS。
先决条件
- 一台运行 Alma Linux 8 的服务器。
- 用您的服务器 IP 指向的有效域名。
- 在服务器上配置了根密码。
安装 LAMP 服务器
Joomla 运行在网络服务器上,用 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
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 网络服务器的状态:
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 安装。您将被重定向到以下屏幕:

选择您的语言,提供您的网站名称,然后单击设置登录数据。您应该看到管理配置屏幕:

提供您的管理员用户名和密码,然后单击设置数据库连接。您应该看到以下屏幕:

提供您的数据库名称、用户名、密码,然后单击安装 Joomla 按钮。安装 Joomla 后,您应该会看到以下屏幕:

单击“打开管理员”按钮。您应该看到 Joomla 登录屏幕:

提供您的管理员用户名和密码,然后单击“登录”按钮。您应该在以下屏幕上看到 Joomla 仪表板:

使用 Lets Encrypt SSL 保护 Joomla CMS
接下来,您需要安装 Certbot 客户端来为您的网站安装 Lets Encrypt SSL。您可以使用以下命令安装它:
dnf install epel-release -y
dnf install certbot python3-certbot-apache
接下来,使用以下命令为您的 lets 域获取并安装 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):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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: ).
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 和 Lets Encrypt SSL 的 Joomla CMS。使用出色的 Joomla CMS,您现在可以在没有任何编程或编码知识的情况下构建自己的网站。如果您有任何疑问,请随时询问。