如何在Debian 9上安装Vanilla论坛

如何在Debian 9上安装Vanilla论坛

Vanilla是一个用PHP编写的免费开源论坛。 Vanilla Forum软件根据GNU GPL2许可证分发。它的源代码可以通过Github获得。它有一个丰富的附加系统,您可以利用它来为您的Vanilla论坛添加自定义功能。 Vanilla论坛的内容可以使用Markdown语言编写。在本教程中,我将向您展示如何使用Nginx作为Web服务器,MariaDB作为数据库服务器在Debian 9上安装Vanilla Forum,并且您可以选择使用acme.sh客户端和Let的加密货币证书颁发机构来保护传输层SSL支持。

要求

Vanilla需要一台带有PHP,MySQL和Web服务器软件的服务器(如Apache或Nginx)。如果要在生产服务器上安装,您可能需要拥有一个域,并且已经在您的服务器上配置了DNS,但如果没有,那么您不需要域。

香草论坛的最低要求是:

  • PHP 7.0或更高版本。
  • PHP扩展mbstring,cURL,GD和PDO,MySQLi,OpenSSL。
  • MySQL 5.0或更新版本(或Percona / MariaDB等效版本)。
  • Web服务器软件(Nginx,Apache ……)。
  • MySQL严格模式已禁用。

香草论坛强烈建议:

  • PHP 7.2或更高版本。
  • PHP扩展mbstring,cURL,GD和PDO,MySQLi,OpenSSL。
  • MySQL 5.7或更新版本(或Percona / MariaDB等效版本)。
  • Web服务器软件(Nginx,Apache ……)。
  • SSL加密货币。

注意:PHP 7.0已达到使用寿命并且将不再接收安全修补程序,因此强烈建议使用较新的PHP版本。 Vanilla对PHP 7.0的支持即将结束

先决条件

  • 运行Debian 9的操作系统。
  • 具有sudo权限的非root用户。

初步步骤

检查你的Debian版本:

lsb_release -ds
# Debian GNU/Linux 9.7 (stretch)

设置时区:

sudo dpkg-reconfigure tzdata

更新操作系统软件包(软件)。这是重要的第一步,因为它可确保您拥有适用于操作系统默认软件包的最新更新和安全修复程序:

sudo apt update && sudo apt upgrade -y

安装一些Debian操作系统基本管理所必需的基本软件包:

sudo apt install -y curl wget vim git unzip socat bash-completion apt-transport-https lsb-release ca-certificates dirmngr software-properties-common

第1步 – 安装PHP和必要的PHP扩展

将新repo添加到系统以安装较新的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

安装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 php7.2-json

要显示在模块中编译的PHP,您可以运行:

php -m

ctype
curl
exif
fileinfo
. . .
. . .

检查PHP版本:

php --version

# 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

在Debian 9系统上重启时会自动启动并启用PHP-FPM服务,因此无需手动启动和启用它。我们可以继续下一步,即数据库安装和设置。

第2步 – 安装MariaDB并为Vanilla Forum创建数据库

Vanilla Forum支持MySQL,MariaDB和Percona数据库。在本教程中,我们将使用MariaDB作为数据库服务器。

从官方MariaDB repo for Debian安装MariaDB版本10.2:

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

检查MariaDB版本:

mysql --version

mysql_secure installation 用于改进MariaDB安全性并设置MariaDB密码的脚本 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用户身份连接到MariaDB shell:

sudo mysql -u root -p
# Enter password

为Vanilla Forum创建一个空的MariaDB数据库和用户并记住凭据:

mariadb> CREATE DATABASE dbname;
mariadb> GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'mypassword';
mariadb> FLUSH PRIVILEGES;

将mypassword替换为您选择的安全密码。退出MariaDB:

mariadb> exit

更换 dbnameusernamepassword 用你自己的名字。

第3步 – 安装acme.sh客户端并获取Let的加密货币证书(可选)

不需要使用HTTPS保护您的网站,但保护您的网站流量是一种很好的做法。为了从Let's Encrypt获取TLS证书,我们将使用acme.sh客户端。 Acme.sh是一个纯Unix shell软件,用于从Let's Encrypt获得TLS证书,零依赖。

下载并安装acme.sh:

sudo su - root
git clone https://github.com/Neilpang/acme.sh.git
cd acme.sh
./acme.sh --install --accountemail (email protected)
source ~/.bashrc
cd ~

检查acme.sh版本:

acme.sh --version
# v2.8.0

获取域/主​​机名的RSA和ECC / ECDSA证书:

# 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天自动续订一次。

获得certs退出root用户并返回正常的sudo用户后:

exit

第4步 – 安装NGINX并为Vanilla Forum配置NGINX

Vanilla Forum可以与许多流行的Web服务器软件一起使用。在本教程中,我们选择了Nginx。如果您更喜欢Apache Web服务器而不是Nginx,请访问https://docs.vanillaforums.com/developer/backend/server-apache/以了解更多信息。

从Debian存储库下载并安装Nginx:

sudo apt install -y nginx

检查Nginx版本:

sudo nginx -v

运行以下命令为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/。

激活新的 vanilla.conf 通过将文件链接到的配置 sites-enabled 目录。

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 Forum应驻留的文档根目录:

sudo mkdir -p /var/www/vanilla

改变所有权 /var/www/vanilla 目录到{your_user}. Replace the string {your_user} with the name of the Linux user that you are currently logged in, so when your username is e.g. johndoe, then replace '{your_user}' with 'johndoe'.

sudo chown -R {your_user}:{your_user} /var/www/vanilla

注意:替换{jour_user} 使用您最初创建的非root用户用户名。

导航到文档根目录:

cd /var/www/vanilla

下载Vanilla论坛zip存档:

wget https://open.vanillaforums.com/get/vanilla-core-2.8.1.zip

提取并删除Vanilla zip存档:

unzip vanilla-core-2.8.1.zip
rm vanilla-core-2.8.1.zip
mv vanilla-2.8.1/* . && mv vanilla-2.8.1/.* .

提供适当的所有权:

sudo chown -R www-data:www-data /var/www/vanilla

导航到您在Web浏览器中上传Vanilla的文件夹,然后按照屏幕上的说明进行操作。

第6步 – 完成香草论坛安装和设置

在Web浏览器中打开您的站点后,您应该被重定向到以下页面:

香草论坛安装程序

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

关于Ubuntu 18.04 LTS的香草论坛

链接

  • https://open.vanillaforums.com/
  • https://github.com/vanilla/vanilla

资讯来源:由0x资讯编译自HOWTOFORGE,版权归作者所有,未经许可,不得转载
你可能还喜欢