注:本教程在Vultr VPS上测试通过,如需部署请前往Vultr.com
香草 是一个用PHP编写的简单讨论论坛。 Vanilla源代码公开托管在 Github。本指南将引导您在使用PHP,MariaDB作为数据库以及Nginx作为Web服务器的全新Debian 9 Vultr服务器实例上完成Vanilla安装过程。
要求
香草论坛推荐的软件堆栈:
PHP 7.2或更高版本,具有以下扩展名:
mbstring
curl
gd
PDO
mysqli
openssl
MySQL 5.7或更高版本,或等效的MariaDB。本指南将使用MariaDB10.2.x。
Web服务器软件,例如Nginx或Apache。本指南将使用Nginx。
SSL加密
在你开始之前
检查Debian版本。
lsb_release -ds
# Debian GNU/Linux 9.7 (stretch)
确保您的系统是最新的。
apt update && apt upgrade -y
如果未安装一些基本的系统管理软件包,请安装它们。
apt install -y vim sudo curl wget git unzip bash-completion apt-transport-https lsb-release ca-certificates dirmngr
创建一个新的 non-root
用户帐户 sudo
访问并切换到它。
adduser johndoe --gecos "John Doe"
usermod -aG sudo johndoe
su - johndoe
注意:更换 johndoe
使用您的用户名。
设置时区。
sudo dpkg-reconfigure tzdata
安装PHP
安装PHP 7.2和PHP扩展。
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt update && sudo apt upgrade -y
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 php7.2-json
检查版本。
php -v
# PHP 7.2.14-1+0~20190113100742.14+stretch~1.gbpd83c69 (cli) (built: Jan 13 2019 10:07:43) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.2.14-1+0~20190113100742.14+stretch~1.gbpd83c69, Copyright (c) 1999-2018, by Zend Technologies
检查已安装的PHP扩展。
php -m
# mbstring
# curl
# gd
# PDO
# mysqli
# openssl
# . . .
安装MariaDB
安装MariaDB 10.2。
sudo apt install -y software-properties-common dirmngr
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] https://mirrors.nxthost.com/mariadb/repo/10.2/debian stretch main'
sudo apt update
sudo apt install -y mariadb-server
检查版本。
mysql --version
# mysql Ver 15.1 Distrib 10.2.21-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
跑过 mysql_secure_installation
脚本以提高安装的安全性。
sudo mysql_secure_installation
以root用户身份登录MariaDB。
sudo mysql -u root -p
# Enter password:
创建一个新的数据库和用户并记住凭据。
CREATE DATABASE dbname;
GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit;
安装Nginx
安装Nginx。
sudo apt install -y nginx
检查版本。
sudo nginx -v
# nginx version: nginx/1.10.3
配置Nginx以与Vanilla论坛一起使用。
sudo vim /etc/nginx/sites-available/vanilla.conf
用以下内容填充文件。
server {
listen 80;
server_name example.com;
root /var/www/vanilla;
index index.php;
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 /image/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.conf
通过将文件链接到 sites-enabled
目录。
sudo ln -s /etc/nginx/sites-available/vanilla.conf /etc/nginx/sites-enabled
测试配置。
sudo nginx -t
重新加载Nginx。
sudo systemctl reload nginx.service
安装香草论坛
创建一个文档根目录。
sudo mkdir -p /var/www/vanilla
更改所有权 /var/www/vanilla
目录到 johndoe
。
sudo chown -R johndoe:johndoe /var/www/vanilla
导航到文档根目录。
cd /var/www/vanilla
下载 最新的香草论坛。
wget https://open.vanillaforums.com/get/vanilla-core-2.6.4.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的文件夹,然后按照屏幕上的说明完成设置。
注:本教程在Vultr VPS上测试通过,如需部署请前往Vultr.com