如何在 Ubuntu 22.04 上使用 Apache 和免费的 Lets Encrypt SSL 安装 phpBB 论坛
在此页
- 先决条件
- 安装 Apache、MariaDB 和 PHP
- 为 phpBB 创建数据库
- 下载 phpBB
- 为 phpBB 配置 Apache
- 访问 phpBB 网络界面
- 使用 Lets Encrypt SSL 保护 phpBB
- 结论
phpBB 是免费的开源论坛软件,为人们提供了一个聚会和相互交流的空间。它是用 PHP 编写的,使用 MariaDB 作为数据库后端。它提供了一组丰富的功能,包括子论坛、用户组、全文搜索、插件和电子邮件通知。它是完全可扩展和可定制的,并且具有用户友好的界面和直接的管理选项。
这篇文章将向您展示如何在 Ubuntu 22.04 上安装带有 Apache 的 phpBB 和 Lets Encrypt SSL。
先决条件
- 一台运行 Ubuntu 22.04 的服务器。
- 用您的服务器 IP 指向的有效域名。
- 在服务器上配置了根密码。
安装 Apache、MariaDB 和 PHP
首先,您需要在您的服务器上安装 Apache 网络服务器、MariaDB 数据库服务器、PHP 和其他软件包。您可以通过运行以下命令来安装所有这些:
apt install apache2 mariadb-server php libapache2-mod-php php-gd php-curl openssl php-imagick php-intl php-json php-ldap php-common php-mbstring php-mysql php-imap php-sqlite3 php-net-ftp php-zip unzip php-pgsql php-ssh2 php-xml wget unzip -y
安装所有包后,使用以下命令启动并启用 Apache 服务:
systemctl start apache2
systemctl enable apache2
为 phpBB 创建数据库
phpBB 使用 MariaDB 来存储他们的数据。所以你需要为 phpBB 创建一个数据库和用户。首先,使用以下命令登录到 MariaDB shell:
mysql
登录后,使用以下命令创建数据库和用户:
MariaDB [(none)]> CREATE DATABASE phpdb;
MariaDB [(none)]> GRANT ALL ON phpdb.* to 'phpuser'@'localhost' IDENTIFIED BY 'password';
接下来,使用以下命令刷新权限并退出 MariaDB:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
完成后,您可以继续下一步。
下载 phpBB
接下来,您需要从其官方下载页面下载最新版本的 phpBB。您可以使用以下命令下载它:
wget https://download.phpbb.com/pub/release/3.3/3.3.7/phpBB-3.3.7.zip
下载 phpBB 后,使用以下命令解压缩下载的文件:
unzip phpBB-3.3.7.zip
接下来,将提取的目录移动到 Apache web 根目录:
mv phpBB3 /var/www/html/phpbb
接下来,更改 phpbb 目录的所有权和权限:
chown -R www-data:www-data /var/www/html/phpbb
chmod -R 775 /var/www/html/phpbb
完成后,您可以继续下一步。
为 phpBB 配置 Apache
接下来,您必须创建一个 Apache 虚拟主机配置文件来托管 phpBB。您可以使用以下命令创建它:
nano /etc/apache2/sites-available/phpbb.conf
添加以下行:
<VirtualHost *:80>
ServerAdmin
DocumentRoot /var/www/html/phpbb
ServerName phpbb.example.com
<Directory /var/www/html/phpbb>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/phpbb_error.log
CustomLog ${APACHE_LOG_DIR}/phpbb_access.log combined
</VirtualHost>
完成后保存并关闭文件,然后使用以下命令启用 Apache 虚拟主机和重写模块:
a2ensite phpbb
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 2022-05-28 10:50:04 UTC; 2s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 22212 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 22217 (apache2)
Tasks: 6 (limit: 2292)
Memory: 15.8M
CPU: 98ms
CGroup: /system.slice/apache2.service
??22217 /usr/sbin/apache2 -k start
??22218 /usr/sbin/apache2 -k start
??22219 /usr/sbin/apache2 -k start
??22220 /usr/sbin/apache2 -k start
??22221 /usr/sbin/apache2 -k start
??22222 /usr/sbin/apache2 -k start
May 28 10:50:04 ubuntu2204 systemd[1]: Starting The Apache HTTP Server...
访问 phpBB 网页界面
现在,打开您的网络浏览器并使用 URL http://phpbb.example.com 访问 phpBB 网络界面。您应该会看到以下页面:

单击“安装”选项卡,然后单击“安装”按钮开始安装。您应该会看到以下页面:

提供您的管理员用户名、密码,然后单击“提交”按钮。您应该会看到以下页面:

提供您的数据库主机、端口、数据库名称、用户名、密码,然后单击“提交”按钮。您应该会看到以下页面:

提供您的协议、网站域名、端口、路径,然后单击“提交”按钮。您应该会看到以下页面:

提供您的 SMTP 详细信息并单击“提交”按钮。您应该会看到以下页面:

选择您的语言、看板名称、看板描述,然后单击“提交”按钮。您应该会看到以下页面:

单击带我到 ACP 按钮。您应该在以下页面上看到 phpBB 控制面板:

使用 Lets Encrypt SSL 保护 phpBB
使用 Lets Encrypt SSL 保护您的网站始终是个好主意。您将需要安装 Certbot 客户端来安装和管理 SSL。您可以使用以下命令安装它:
apt-get install python3-certbot-apache -y
安装 Certbot 后,运行以下命令以使用 Lets Encrypt SSL 保护您的网站:
certbot --apache -d phpbb.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 phpbb.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/phpbb-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/phpbb-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/phpbb-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/phpbb.conf to ssl vhost in /etc/apache2/sites-available/phpbb-le-ssl.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://phpbb.example.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=phpbb.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/phpbb.example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/phpbb.example.com/privkey.pem
Your cert will expire on 2022-08-12. 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://phpbb.example.com 安全地访问您的网站。
结论
恭喜!您已经在 Ubuntu 22.04 上成功安装了带有 Apache 和 Lets Encrypt SSL 的 phpBB。您现在可以探索 phpBB 控制面板并开始创建您的第一个面板。