如何在 Ubuntu 22.04 上安装 ElkArte 论坛软件
ElkArte是一款用PHP语言编写的免费开源论坛软件。它基于简单机器论坛,可帮助您轻松创建社区论坛。它已经发展成为一个现代且功能丰富的论坛包,可以满足当今留言板用户的需求。它提供了社区创建的各种主题和插件,可帮助您扩展 ElkArte 功能。
本教程将向您展示如何使用 Let's Encrypt SSL 在 Ubuntu 22.04 上安装 ElkArte。
先决条件
- 运行 Ubuntu 22.04 的服务器。
- 您的服务器指向一个有效的域名。
- 您的服务器上配置了 root 密码。
安装 Apache、PHP 和 MariaDB
ElkArte运行在基于PHP的Web服务器上,并使用MariaDB作为数据库后端。因此,您需要在服务器上安装 Apache、MariaDB、PHP 和其他 PHP 扩展。
首先,使用以下命令安装 Apache 和 MariaDB 服务器:
apt install apache2 mariadb-server
接下来,您需要在服务器上安装 PHP 7.4 版和其他所需的扩展。默认情况下,Ubuntu 22.04 在其默认存储库中附带 PHP 版本 8.1。因此,您需要将 Ondrej PHP 存储库安装到您的服务器上。
apt install software-properties-common -y
add-apt-repository ppa:ondrej/php -y
将 PHP 存储库添加到服务器后,您可以使用以下命令安装 PHP:
apt install php7.4 libapache2-mod-php7.4 php7.4-common php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-mysql php7.4-gd php7.4-pgsql php7.4-xml php7.4-cli php7.4-imagick php7.4-bcmath php7.4-gmp php7.4-zip unzip -y
安装所有软件包后,打开 php.ini 文件并更改默认设置:
nano /etc/php/7.4/apache2/php.ini
更改以下行:
Change the following lines:
memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = Asia/Kolkata
保存并关闭文件,然后重新启动 Apache 服务以应用更改:
systemctl restart apache2
配置 MariaDB 数据库
首先,保护 MariaDB 安装并使用以下命令设置 MariaDB root 密码:
mysql_secure_installation
回答所有问题,如下所示:
Enter current password for root (enter for none):
Set root password? [Y/n] Y
New password:
Re-enter new password:
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
接下来,使用以下命令登录 MariaDB shell:
mysql -u root -p
登录后,为ElkArte创建数据库和用户:
MariaDB [(none)]> CREATE DATABASE elkdb;
MariaDB [(none)]> CREATE USER 'elk'@'localhost' IDENTIFIED BY 'password';
接下来,使用以下命令向 elkdb 授予所有权限:
MariaDB [(none)]> GRANT ALL ON elkdb.* TO 'elk'@'localhost' WITH GRANT OPTION;
接下来,使用以下命令刷新权限并退出 MariaDB shell:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
配置数据库后,您可以继续下一步。
下载ElkArte
首先,使用以下命令从 Git 存储库下载最新版本的 ElkArte:
wget https://github.com/elkarte/Elkarte/releases/download/v1.1.8/ElkArte_v1-1-8_install.zip
下载完成后,使用以下命令将下载的文件解压到 Apache Web 根目录:
unzip ElkArte_v1-1-8_install.zip -d /var/www/html/elkarte
接下来,使用以下命令为 elkarte 目录授予适当的权限:
chown -R www-data:www-data /var/www/html/elkarte/
chmod -R 755 /var/www/html/elkarte/
完成后,您可以继续下一步。
为 ElkArte 配置 Apache
接下来,为 ElkArte 创建一个新的 Apache 虚拟主机配置文件。
nano /etc/apache2/sites-available/elkarte.conf
添加以下行:
<VirtualHost *:80>
ServerAdmin [email
ServerName elk.linuxbuz.com
DocumentRoot /var/www/html/elkarte
<Directory /var/www/html/elkarte/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
完成后保存并关闭文件。然后,使用以下命令启用 Apache 虚拟主机和重写模块:
a2ensite elkarte.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 Sun 2022-09-11 13:35:46 UTC; 9s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 30485 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 30490 (apache2)
Tasks: 6 (limit: 4579)
Memory: 14.9M
CPU: 90ms
CGroup: /system.slice/apache2.service
??30490 /usr/sbin/apache2 -k start
??30549 /usr/sbin/apache2 -k start
??30550 /usr/sbin/apache2 -k start
??30551 /usr/sbin/apache2 -k start
??30552 /usr/sbin/apache2 -k start
??30553 /usr/sbin/apache2 -k start
Sep 11 13:35:46 ubuntu2204 systemd[1]: Starting The Apache HTTP Server...
访问 ElkArte 网页界面
现在,打开您的网络浏览器并输入 URL https://elk.linuxbuz.com。您将被重定向到 ElkArte 欢迎页面:
单击继续按钮。您应该看到数据库服务器设置页面:
提供您的数据库详细信息,然后单击继续按钮。您应该看到论坛设置页面:
提供您的论坛 URL、论坛名称,然后单击继续按钮。您应该看到以下页面:
单击继续按钮。您应该看到管理员帐户创建页面:
提供您的管理员用户名、密码、电子邮件,然后单击继续按钮。安装完成后,您应该看到以下页面:
单击新安装的论坛。您应该在以下页面上看到 ElkArte 仪表板:
使用 Let's Encrypt SSL 保护 ElkArte
首先,安装 Certbot Let's Encrypt 客户端来管理您网站的 SSL:
apt-get install certbot python3-certbot-apache -y
安装 Certbot 后,运行以下命令为您的网站下载并安装 Let's Encrypt SSL:
certbot --apache -d elk.linuxbuz.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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for elk.linuxbuz.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/elk-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/elk-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/elk-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 键完成安装,如下所示。
Redirecting vhost in /etc/apache2/sites-enabled/elk.conf to ssl vhost in /etc/apache2/sites-available/elk-le-ssl.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://elk.linuxbuz.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=elk.linuxbuz.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/elk.linuxbuz.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/elk.linuxbuz.com/privkey.pem
Your cert will expire on 2020-08-19. 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"
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
- 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
- We were unable to subscribe you the EFF mailing list because your
e-mail address appears to be invalid. You can try again later by
visiting https://act.eff.org.
此时,您的 ElkArte 已通过 Let's Encrypt SSL 进行保护。
结论
恭喜!您已在 Ubuntu 22.04 上成功安装了带有 Let's Encrypt SSL 的 ElkArte。您现在可以使用 ElkArte 轻松举办您自己的社区论坛。如果您有任何疑问,请随时问我。