How to Install Vanilla Forum on CentOS 7
This tutorial exists for these OS versions
- CentOS 8
- CentOS 7
On this page
- Requirements
- Prerequisites
- Initial steps
- Step 1 - Install PHP and necessary PHP extensions
- Step 2 - Install MariaDB and create a database for Vanilla Forum
- Step 3 - Install
acme.sh
client and obtain Let">) - Step 4 - Install NGINX and configure NGINX for Vanilla Forum
- Step 5 - Install Vanilla Forum
- Step 6 - Complete the Vanilla Forum Installation and Setup
- Links
Vanilla is free, open-source discussion forum written in PHP. Vanilla Forum software is distributed under the GNU GPL2 license. Its source code is available through Github. It has a rich add-on system that you can take advantage of to add custom features to your Vanilla forum. Content for Vanilla Forum can be written using the Markdown language. In this tutorial, we will go through the Vanilla Forum installation and setup on CentOS 7 system by using Nginx as a web server, MySQL as a database server, and optionally you can secure transport layer by using acme.sh client and Let's Encrypt certificate authority to add SSL support.
Requirements
Vanilla requires a server with PHP, MySQL, and web server software (like Apache or Nginx). You'll probably need to own a domain, and already have it configured on your server with DNS if you want to install on a production server, but if not then you don't need a domain.
Vanilla Forum minimum requirements are:
- PHP version 7.0 or newer.
- PHP extensions mbstring, cURL, GD, and PDO, MySQLi, OpenSSL.
- MySQL version 5.0 or newer (or Percona/MariaDB equivalent).
- Web Server software (Nginx, Apache ...).
- MySQL strict mode disabled.
Vanilla Forum strongly recommends:
- PHP version 7.2 or newer.
- PHP extensions mbstring, cURL, GD, and PDO, MySQLi, OpenSSL.
- MySQL version 5.7 or newer (or Percona/MariaDB equivalent).
- Web server software (Nginx, Apache ...).
- SSL encryption.
NOTE: PHP 7.0 has reached end of life and will no longer receive security patches, so it's highly recommended to use newer PHP versions. Vanilla's support for PHP 7.0 will end soon!
Prerequisites
- An operating system running CentOS 7.
- A non-root user with sudo privileges.
Initial steps
Check your CentOS version:
cat /etc/centos-release
# CentOS Linux release 7.6.1810 (Core)
Set up the timezone:
timedatectl list-timezones
sudo timedatectl set-timezone 'Region/City'
Update your operating system packages (software). This is an important first step because it ensures you have the latest updates and security fixes for your operating system's default software packages:
sudo yum update -y
Install some essential packages that are necessary for basic administration of the CentOS operating system:
sudo yum install -y curl wget vim git unzip socat bash-completion epel-release
Step 1 - Install PHP and necessary PHP extensions
Setup the Webtatic YUM repo:
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Install PHP, as well as the necessary PHP extensions:
sudo yum install -y php72w php72w-cli php72w-fpm php72w-common php72w-mbstring php72w-curl php72w-gd php72w-mysql
To show PHP compiled in modules, you can run:
php -m
ctype
curl
exif
fileinfo
. . .
. . .
Check PHP version:
php --version
# PHP 7.2.14 (cli) (built: Jan 12 2019 12:47:33) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Start and enable PHP-FPM service:
sudo systemctl start php-fpm.service
sudo systemctl enable php-fpm.service
We can move on to the next step, which is database installation and setup.
Step 2 - Install MariaDB and create a database for Vanilla Forum
Vanilla Forum supports MySQL, MariaDB and Percona databases. In this tutorial, we will use MariaDB as database server. Since default CentOS 7 repositories contain very old MariaDB version that is not compatible with Vanilla Forum, we will need to use the official MariaDB repo to install a newer version.
Create MariaDB 10.2 YUM repository for CentOS:
sudo vim /etc/yum.repos.d/MariaDB.repo
Copy and paste the following text into it:
# MariaDB 10.2 CentOS repository list - created 2017-12-11 23:19 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name=MariaDB
baseurl=https://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
After the file is in place, install MariaDB by running:
sudo yum install -y MariaDB-server MariaDB-client
Check the MariaDB version:
mysql --version
# mysql Ver 15.1 Distrib 10.2.21-MariaDB, for Linux (x86_64) using readline 5.1
Start and enable MariaDB service:
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
Run mysql_secure installation
script to improve MariaDB security and set the password for MariaDB root
user:
sudo mysql_secure_installation
Answer each of the questions:
Enter current password for root (enter for none): Press Enter
Set root password? [Y/n] Y
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
Connect to MariaDB shell as the root user:
sudo mysql -u root -p
# Enter password
Create an empty MariaDB database and user for Vanilla Forum and remember the credentials:
MariaDB [(none)]> CREATE DATABASE dbname;
MariaDB [(none)]> GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
MariaDB [(none)]> FLUSH PRIVILEGES;
Exit from MariaDB:
MariaDB [(none)]> exit
Replace dbname
, username
and password
with your own names.
Step 3 - Install acme.sh
client and obtain Let's Encrypt certificate (optional)
Securing your website with HTTPS is not necessary, but it is a good practice to secure your site traffic. In order to obtain TLS certificate from Let's Encrypt we will use acme.sh client. Acme.sh is a pure unix shell software for obtaining TLS certificates from Let's Encrypt with zero dependencies.
Download and install 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 ~
Check acme.sh version:
acme.sh --version
# v2.8.0
Obtain RSA and ECC/ECDSA certificates for your domain/hostname:
# RSA 2048
acme.sh --issue --standalone -d example.com --keylength 2048
# ECDSA
acme.sh --issue --standalone -d example.com --keylength ec-256
If you want fake certificates for testing you can add --staging
flage to the above commands.
After running the above commands, your certificates and keys will be in:
- For RSA:
/home/username/example.com
directory. - For ECC/ECDSA:
/home/username/example.com_ecc
directory.
To list your issued certs you can run:
acme.sh --list
Create a directories to store your certs. We will use /etc/letsencrypt
directory.
mkdir -p /etc/letsecnrypt/example.com
sudo mkdir -p /etc/letsencrypt/example.com_ecc
Install/copy certificates to /etc/letsencrypt directory.
# 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"
All the certificates will be automatically renewed every 60 days.
After obtaining certs exit form root user and return back to normal sudo user:
exit
Step 4 - Install NGINX and configure NGINX for Vanilla Forum
Vanilla Forum can work fine with many popular web server software. In this tutorial, we selected Nginx. If you prefer Apache web server over Nginx, please visit https://docs.vanillaforums.com/developer/backend/server-apache/ to learn more.
Download and install Nginx from the CentOS repository:
sudo yum install -y nginx
Check the Nginx version:
nginx -v
# nginx version: nginx/1.12.2
Start and enable Nginx service:
sudo systemctl start nginx.service
sudo systemctl enable nginx.service
Configure Nginx for Vanilla by running:
sudo vim /etc/nginx/conf.d/vanilla.conf
And populate the file with the following configuration:
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/ECDSA
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(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $fastcgi_script_name =404;
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.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;
}
}
NOTE: For complete and production ready Nginx config for Vanilla visit https://docs.vanillaforums.com/developer/backend/server-nginx/.
Check Nginx configuration for syntax errors:
sudo nginx -t
Reload Nginx service:
sudo systemctl reload nginx.service
Step 5 - Install Vanilla Forum
Create a document root directory where Vanilla Forum should reside in:
sudo mkdir -p /var/www/vanilla
Change ownership of the /var/www/vanilla
directory to {jour_user}
:
sudo chown -R {your_user}:{your_user} /var/www/vanilla
NOTE: Replace {jour_user}
with your initially created non-root user username.
Navigate to the document root directory:
cd /var/www/vanilla
Download the Vanilla Forum zip archive:
wget https://open.vanillaforums.com/get/vanilla-core-2.6.4.zip
Extract and remove Vanilla zip archive:
unzip vanilla-core-2.6.4.zip
rm vanilla-core-2.6.4.zip
Provide the appropriate ownership:
sudo chown -R nginx:nginx /var/www/vanilla
Run sudo vim /etc/php-fpm.d/www.conf
and set the user and group to nginx
. Initially, they will be set to apache:
sudo vim /etc/php-fpm.d/www.conf
# user = nginx
# group = nginx
Navigate to the folder where you uploaded Vanilla in your web browser and follow the instructions on the screen.
Step 6 - Complete the Vanilla Forum Installation and Setup
After opening your site in a web browser, you should be redirected to the following page:
Fill in the required information and click on the "Continue →" button to finish up the installation and setup. After that Vanilla Forum admin interface should appear.