如何在Debian 9上安装Vanilla论坛
Haojinghui
・8 分钟阅读
使用不同的系统?
Vanilla是一个用PHP编写的简单论坛,Vanilla源代码公开托管在GitHub ,本指南会使用PHP,MariaDB作为数据库和Nginx作为Web服务器,在新的Debian 9服务器实例上引导你完成Vanilla安装过程。
要求
Vanilla论坛推荐软件栈:
- PHP版本7.2或更高版本,有以下扩展名:
mbstring
curl
gd
PDO
mysqli
openssl
- MySQL版本5.7或更高,或MariaDB等效,本指南将使用MariaDB 10.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
使用sudo
访问创建一个新的non-root
用户帐户,并且切换到它。
adduser johndoe --gecos"John Doe"
usermod -aG sudo johndoe
su - johndoe
注:会johndoe
替换为你的用户名。
设置时区。
sudo dpkg-reconfigure tzdata
安装PHP
Install 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 /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;
}
}
通过会文件链接到sites-enabled
目录来激活新的vanilla.conf
配置。
sudo ln -s /etc/nginx/sites-available/vanilla.conf /etc/nginx/sites-enabled
测试配置。
sudo nginx -t
重新加载Nginx 。
sudo systemctl reload nginx.service
安装Vanilla论坛
创建文档root目录。
sudo mkdir -p /var/www/vanilla
会/var/www/vanilla
目录的所有权更改为johndoe
。
sudo chown -R johndoe:johndoe /var/www/vanilla
导航到文档root目录。
cd/var/www/vanilla
下载最新的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
导航到你在网页浏览器中上传的文件夹,并按照屏幕上的指示完成设置。