如何在Fedora 29上安装Vanilla论坛
Haojinghui
・8 分钟阅读
使用不同的系统?
介绍
Vanilla是一个用PHP编写的简单讨论论坛,Vanilla源代码公共托管在GitHub ,本指南会使用PHP,MariaDB作为数据库和Nginx作为Web服务器,在新的Fedora 29服务器实例上引导你完成Vanilla安装过程。
要求
Vanilla论坛推荐软件栈:
- PHP版本7.2或更高版本,有以下扩展名:
mbstring
curl
gd
PDO
mysqli
openssl
,
- MySQL版本5.7或更高; 或者等效的Percona或Mariadb 本指南将使用MariaDB ,
- Web服务器软件,如Nginx或Apache ,本指南将使用Nginx ,
- SSL加密,
开始之前
检查Fedora版本。
cat /etc/fedora-release
# Fedora release 29 (Twenty Nine)
使用sudo
访问创建一个新的non-root
用户帐户,并且切换到它。
useradd -c"John Doe" johndoe && passwd johndoe
usermod -aG wheel johndoe
su - johndoe
注:会johndoe
替换为你的用户名。
设置时区。
timedatectl list-timezones
sudo timedatectl set-timezone 'Region/City'
确保你的系统是最新的。
sudo dnf check-update; sudo dnf update -y
如果未安装一些基本系统管理包,请安装它们。
sudo dnf install -y vim curl wget git unzip bash-completion
为简便起见,请禁用SELinux和防火墙。
sudo setenforce 0;sudo systemctl stop firewalld;sudo systemctl disable firewalld
安装PHP
Install PHP 7.2和PHP扩展。
sudo dnf install -y php-cli php-fpm php-common php-mbstring php-curl php-gd php-pdo php-mysqlnd php-json
检查版本。
php --version
# PHP 7.2.14 (cli) (built: Jan 8 2019 09:59:17) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
检查已安装的PHP扩展。
php -m
# mbstring
# curl
# gd
# PDO
# mysqli
# openssl
# . . .
启动并启用php fpm 。
sudo systemctl start php-fpm.service
sudo systemctl enable php-fpm.service
安装MariaDB
安装MariaDB 。
sudo dnf install -y mariadb-server
检查版本。
mysql --version
# mysql Ver 15.1 Distrib 10.3.11-MariaDB, for Linux (x86_64) using readline 5.1
启动并启用MariaDB 。
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
运行mysql_secure_installation
脚本以提高MariaDB安装的安全性。
sudo mysql_secure_installation
以root用户身份登录到MariaDB 。
mysql -u root -p
# Enter password:
创建新数据库和用户,记住这个新用户的凭证。
CREATE DATABASE dbname;
GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit;
安装Nginx
安装Nginx 。
sudo dnf install -y nginx
检查版本。
nginx -v
# nginx version: nginx/1.14.1
启动并启用Nginx 。
sudo systemctl start nginx.service
sudo systemctl enable nginx.service
配置Nginx for Vanilla论坛。
sudo vim /etc/nginx/conf.d/vanilla.conf
使用以下配置填充文件。
server {
listen 80;
server_name forum.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 default.d/php.conf;
fastcgi_param SCRIPT_NAME /index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root/index.php;
fastcgi_param X_REWRITE 1;
fastcgi_pass 127.0.0.1:9000;
}
location ~* .php(/|$) {
rewrite ^ /index.php$uri last;
}
location / {
try_files $uri $uri/ @vanilla;
}
location @vanilla {
rewrite ^ /index.php$uri last;
}
}
测试配置。
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 nginx:nginx /var/www/vanilla
运行sudo vim/etc/php-fpm.d/www.conf
并会用户和组设置为nginx
,最初,它会被设置为apache
。
sudo vim /etc/php-fpm.d/www.conf
# user = nginx
# group = nginx
重新启动php fpm 。
sudo systemctl restart php-fpm.service
导航到你在网页浏览器中上传的文件夹,并按照屏幕上的指示完成设置。