本页内容
- 先决条件
- 安装 LAMP 服务器
- 配置 MariaDB 数据库
- 安装 phpBB(Debian 11)
- 为 phpBB 创建 Apache 虚拟主机
- 访问 phpBB Web 界面
- 为 phpBB 论坛启用 SSL
- 结语
phpBB 是一款免费且开源的电子公告板(论坛)软件,可让你与一群人保持联系。它可以为你的整个网站提供动力,并为人们提供一个聚集和相互交流的空间。它提供基于 Web 的界面,人们可以在其中发布主题,其他人则可以对这些主题进行回复。借助 phpBB,你可以分配角色、创建角色扮演列表、启用特殊权限、向社区发送新闻邮件,以及创建自定义内容。如果你想创建论坛式的讨论板,那么 phpBB 是一个非常适合你的工具。
本文将会向你展示如何在 Debian 11 上配合 Apache 和 Let's Encrypt SSL 安装 phpBB。
先决条件
- 你的系统上已安装 Debian 11 服务器。
- 一个有效的域名已指向你的服务器 IP。
- 服务器上已配置 root 密码。
安装 LAMP 服务器
phpBB 使用 PHP 编写,并以 MariaDB 作为数据库后端。因此,你需要在服务器上安装 Apache Web 服务器、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
配置 MariaDB 数据库
接下来,你需要为 phpBB 创建一个数据库和用户。首先,使用以下命令登录 MariaDB shell:
mysql
登录后,使用以下命令创建数据库和用户:
MariaDB [(none)]> CREATE DATABASE phpbbdb;
MariaDB [(none)]> GRANT ALL ON phpbbdb.* to 'phpbbuser'@'localhost' IDENTIFIED BY 'password';
接下来,使用以下命令刷新权限并退出 MariaDB:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
完成后,你可以进入下一步。
安装 phpBB(Debian 11)
首先,访问 phpBB 官方网站,并使用以下命令下载最新版本的 phpBB。
wget https://download.phpbb.com/pub/release/3.3/3.3.9/phpBB-3.3.9.zip
下载成功后,使用以下命令解压下载的文件:
unzip phpBB-3.3.9.zip
接下来,将解压出来的目录移动到 Apache 网站根目录:
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
[email protected]
DocumentRoot /var/www/html/phpbb
ServerName phpbb3.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 虚拟主机和 rewrite 模块:
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 Fri 2022-12-30 04:44:52 UTC; 5s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 17472 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 17476 (apache2)
Tasks: 6 (limit: 4675)
Memory: 16.4M
CPU: 108ms
CGroup: /system.slice/apache2.service
??17476 /usr/sbin/apache2 -k start
??17477 /usr/sbin/apache2 -k start
??17478 /usr/sbin/apache2 -k start
??17479 /usr/sbin/apache2 -k start
??17480 /usr/sbin/apache2 -k start
??17481 /usr/sbin/apache2 -k start
Dec 30 04:44:52 debian11 systemd[1]: Starting The Apache HTTP Server...
至此,phpBB 已配合 Apache Web 服务器安装完成。你现在可以继续访问 phpBB Web 界面了。
访问 phpBB Web 界面
现在,打开你的 Web 浏览器,并使用 URL http://phpbb3.example.com 访问 phpBB Web 界面。你应该会看到如下页面:

点击 INSTALL(安装)标签页。你应该会看到如下页面。

现在,点击 Install(安装)按钮开始安装。你应该会看到如下页面:

设置你的管理员用户名和密码,然后点击 Submit(提交)按钮。你应该会看到如下页面:

填写你的数据库主机、端口、数据库名称、用户名、密码,然后点击 Submit(提交)按钮。你应该会看到如下页面:

填写你的协议、网站域名、端口、路径,然后点击 Submit(提交)按钮。你应该会看到如下页面:

输入你的 SMTP 详细信息,然后点击 Submit(提交)按钮。你应该会看到如下页面:

选择你的语言、论坛名称和论坛描述,然后点击 Submit(提交)按钮。你应该会看到如下页面:

点击 Take me to the ACP(进入管理控制面板)按钮。你应该在下一页看到 phpBB 控制面板:

为 phpBB 论坛启用 SSL
要在你的网站上启用 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 phpbb.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 phpbb.example.com Successfully received certificate. Certificate is saved at: /etc/letsencrypt/live/phpbb.example.com/fullchain.pem Key is saved at: /etc/letsencrypt/live/phpbb.example.com/privkey.pem This certificate expires on 2023-03-29. 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 phpbb.example.com to /etc/apache2/sites-available/phpbb.conf Congratulations! You have successfully enabled HTTPS on https://phpbb.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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
现在,你可以使用 URL https://phpbb.example.com 安全地访问你的网站了。
结语
在本文中,我们介绍了如何在 Debian Linux 上配合 Apache 和 Let's Encrypt SSL 安装 phpBB。你现在可以使用 phpBB 在你的组织中创建论坛式的讨论板。如果你有任何问题,欢迎随时向我提问。