如何在 Ubuntu 18.04 LTS 上安装 Vanilla 论坛
在此页
- 要求
- 先决条件
- 初始步骤
- 第 1 步 - 安装 PHP 和必要的 PHP 扩展
- 第 2 步 - 安装 MySQL 并为 Vanilla 论坛创建数据库
- 第 3 步 - 安装
acme.sh
客户端并获取 Let\>) - 第 4 步 - 安装 NGINX 并为 Vanilla 论坛配置 NGINX
- 第 5 步 - 安装 Vanilla 论坛
- 第 6 步 - 完成 Vanilla 论坛的安装和设置
- 链接
Vanilla 是用 PHP 编写的免费开源论坛。 Vanilla 论坛软件根据 GNU GPL2 许可证分发。其源代码可通过 Github 获得。它有一个丰富的附加系统,您可以利用它为您的 Vanilla 论坛添加自定义功能。 Vanilla 论坛的内容可以使用 Markdown 语言编写。在本教程中,我们将使用 Nginx 作为网络服务器,使用 MySQL 作为数据库服务器,在 Ubuntu 18.04 LTS 系统上完成 Vanilla Forum 的安装和设置,您还可以选择使用 acme.sh 客户端和 Lets Encrypt 证书来保护传输层添加 SSL 支持的权限。
要求
Vanilla 需要带有 PHP、MySQL 和 Web 服务器软件(如 Apache 或 Nginx)的服务器。如果你想在生产服务器上安装,你可能需要拥有一个域,并且已经在你的服务器上配置了 DNS,但如果没有,那么你不需要域。
香草论坛最低要求是:
- PHP 版本 7.0 或更高版本。
- PHP 扩展 mbstring、cURL、GD 和 PDO、MySQLi、OpenSSL。
- MySQL 5.0 版或更新版本(或 Percona/MariaDB 等效版本)。
- 网络服务器软件(Nginx、Apache ...)。
- 禁用 MySQL 严格模式。
Vanilla 论坛强烈推荐:
- PHP 版本 7.2 或更高版本。
- PHP 扩展 mbstring、cURL、GD 和 PDO、MySQLi、OpenSSL。
- MySQL 5.7 版或更新版本(或 Percona/MariaDB 等效版本)。
- 网络服务器软件(Nginx、Apache ...)。
- SSL 加密。
注意:PHP 7.0 的生命周期已结束,将不再接收安全补丁,因此强烈建议使用较新的 PHP 版本。对 PHP 7.0 的香草支持即将结束! Ubuntu 18.04 LTS 默认附带 PHP 7.2,因此我们无需担心 PHP 版本。
先决条件
- 运行 Ubuntu 18.04 LTS 的操作系统。
- 具有 sudo 权限的非根用户。
初始步骤
检查您的 Ubuntu 版本:
lsb_release -ds
# Ubuntu 18.04.1 LTS
设置时区:
sudo dpkg-reconfigure tzdata
更新您的操作系统包(软件)。这是重要的第一步,因为它确保您拥有操作系统默认软件包的最新更新和安全修复程序:
sudo apt update && sudo apt upgrade -y
安装 Ubuntu 操作系统基本管理所需的一些基本软件包:
sudo apt install -y curl wget vim git unzip socat bash-completion
第 1 步 - 安装 PHP 和必要的 PHP 扩展
安装 PHP,以及必要的 PHP 扩展:
sudo apt install -y php7.2 php7.2-cli php7.2-fpm php7.2-common php7.2-mbstring php7.2-curl php7.2-gd php7.2-mysql
要显示在模块中编译的 PHP,您可以运行:
php -m
ctype
curl
exif
fileinfo
. . .
. . .
检查 PHP 版本:
php --version
# PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
PHP-FPM服务在Ubuntu 18.04系统重启时自动启动启用,无需手动启动启用。我们可以继续下一步,即数据库安装和设置。
第 2 步 - 安装 MySQL 并为 Vanilla 论坛创建数据库
Vanilla 论坛支持 MySQL、MariaDB 和 Percona 数据库。在本教程中,我们将使用 MySQL 作为数据库服务器。
安装 MySQL 数据库服务器:
sudo apt install -y mysql-server
检查 MySQL 版本:
mysql --version
# mysql Ver 14.14 Distrib 5.7.24, for Linux (x86_64) using EditLine wrapper
运行 mysql_secure installation
脚本以提高 MySQL 安全性并为 MySQL root
用户设置密码:
sudo mysql_secure_installation
回答每个问题:
Would you like to setup VALIDATE PASSWORD plugin? N
New password: your_secure_password
Re-enter new password: your_secure_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
以 root 用户身份连接到 MySQL shell:
sudo mysql -u root -p
# Enter password
为 Vanilla 论坛创建一个空的 MySQL 数据库和用户并记住凭据:
mysql> CREATE DATABASE dbname;
mysql> GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
mysql> FLUSH PRIVILEGES;
退出 MySQL:
mysql> exit
将 dbname
、username
和 password
替换为您自己的名称。
第 3 步 - 安装 acme.sh 客户端并获取 Lets Encrypt 证书(可选)
没有必要使用 HTTPS 保护您的网站,但这是保护您的网站流量的好习惯。为了从 Lets Encrypt 获得 TLS 证书,我们将使用 acme.sh 客户端。 Acme.sh 是一个纯 unix shell 软件,用于以零依赖从 Lets Encrypt 获取 TLS 证书。
下载并安装 acme.sh:
sudo su - root
git clone https://github.com/Neilpang/acme.sh.git
cd acme.sh
./acme.sh --install --accountemail
source ~/.bashrc
cd ~
检查 acme.sh 版本:
acme.sh --version
# v2.8.0
为您的域/主机名获取 RSA 和 ECC/ECDSA 证书:<br>
# RSA 2048
acme.sh --issue --standalone -d example.com --keylength 2048
# ECDSA
acme.sh --issue --standalone -d example.com --keylength ec-256
如果你想要假证书进行测试,你可以在上面的命令中添加 --staging
标记。
运行上述命令后,您的证书和密钥将位于:
- 对于 RSA:
/home/username/example.com
目录。 - 对于 ECC/ECDSA:
/home/username/example.com_ecc
目录。
要列出您颁发的证书,您可以运行:
acme.sh --list
创建一个目录来存储您的证书。我们将使用 /etc/letsencrypt
目录。
mkdir -p /etc/letsecnrypt/example.com
sudo mkdir -p /etc/letsencrypt/example.com_ecc
安装/复制证书到 /etc/letsencrypt 目录。
# RSA
acme.sh --install-cert -d example.com \
--cert-file /etc/letsencrypt/example.com/cert.pem \
--key-file /etc/letsencrypt/example.com/private.key \
--fullchain-file /etc/letsencrypt/example.com/fullchain.pem \
--reloadcmd "sudo systemctl reload nginx.service"
# ECC/ECDSA
acme.sh --install-cert -d example.com --ecc \
--cert-file /etc/letsencrypt/example.com_ecc/cert.pem \
--key-file /etc/letsencrypt/example.com_ecc/private.key \
--fullchain-file /etc/letsencrypt/example.com_ecc/fullchain.pem \
--reloadcmd "sudo systemctl reload nginx.service"
所有证书将每 60 天自动更新一次。
获得证书后退出 root 用户并返回普通 sudo 用户:
exit
第 4 步 - 安装 NGINX 并为 Vanilla 论坛配置 NGINX
Vanilla 论坛可以与许多流行的网络服务器软件一起正常工作。在本教程中,我们选择了 Nginx。如果您更喜欢 Apache 网络服务器而不是 Nginx,请访问 https://docs.vanillaforums.com/developer/backend/server-apache/ 了解更多信息。
从 Ubuntu 存储库下载并安装 Nginx:
sudo apt install -y nginx
检查 Nginx 版本:
sudo nginx -v
# nginx version: nginx/1.14.0 (Ubuntu)
通过运行以下命令为 Vanilla 配置 Nginx:
sudo vim /etc/nginx/sites-available/vanilla.conf
并使用以下配置填充文件:
server {
listen 80;
listen 443 ssl http2;
server_name forum.example.com;
root /var/www/vanilla;
index index.php;
# RSA
ssl_certificate /etc/letsencrypt/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com/private.key;
# ECC
ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com_ecc/private.key;
location ~* /\.git { deny all; return 403; }
location /build/ { deny all; return 403; }
location /cache/ { deny all; return 403; }
location /cgi-bin/ { deny all; return 403; }
location /uploads/import/ { deny all; return 403; }
location /conf/ { deny all; return 403; }
location /tests/ { deny all; return 403; }
location /vendor/ { deny all; return 403; }
location ~* ^/index\.php(/|$) {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_NAME /index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root/index.php;
fastcgi_param X_REWRITE 1;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~* \.php(/|$) {
rewrite ^ /index.php$uri last;
}
location / {
try_files $uri $uri/ @vanilla;
}
location @vanilla {
rewrite ^ /index.php$uri last;
}
}
注意:要获得适用于 Vanilla 的完整和生产就绪的 Nginx 配置,请访问 https://docs.vanillaforums.com/developer/backend/server-nginx/。
通过将文件链接到 sites-enabled
目录来激活新的 vanilla.conf
配置。
sudo ln -s /etc/nginx/sites-available/vanilla.conf /etc/nginx/sites-enabled
检查 Nginx 配置是否有语法错误:
sudo nginx -t
重新加载 Nginx 服务:
sudo systemctl reload nginx.service
第 5 步 - 安装 Vanilla 论坛
创建一个文档根目录,Vanilla 论坛应位于该目录中:
sudo mkdir -p /var/www/vanilla
将 /var/www/vanilla
目录的所有权更改为 {jour_user}
:
sudo chown -R {your_user}:{your_user} /var/www/vanilla
注意:将 {jour_user}
替换为您最初创建的非根用户用户名。
导航到文档根目录:
cd /var/www/vanilla
下载 Vanilla 论坛 zip 存档:
wget https://open.vanillaforums.com/get/vanilla-core-2.6.4.zip
提取并删除 Vanilla zip 存档:
unzip vanilla-core-2.6.4.zip
rm vanilla-core-2.6.4.zip
提供适当的所有权:
sudo chown -R www-data:www-data /var/www/vanilla
在网络浏览器中导航到您上传 Vanilla 的文件夹,然后按照屏幕上的说明进行操作。
第 6 步 - 完成 Vanilla 论坛的安装和设置
在网络浏览器中打开您的网站后,您应该被重定向到以下页面:

填写所需信息并单击“继续→”按钮以完成安装和设置。之后应该会出现 Vanilla 论坛管理界面。

链接
- https://open.vanillaforums.com/
- https://github.com/vanilla/vanilla