Vanilla is a simple discussion forum written in PHP. Vanilla source code is publicly hosted on Github. This guide will walk you through the Vanilla installation process on a fresh Ubuntu 20.04 LTS (Focal Fossa) server instance using PHP, MySQL as a database, and Nginx as a web server.

Requirements

Vanilla Forum recommended software stack:

  • PHP version 7.2 or greater. PHP 7.3 or greater strongly recommended. This guide will use PHP 7.4.x.
  • PHP extensions: mbstring, curl, gd, PDO, mysqli, openssl, gd, pdo.
  • MySQL version 5.7 or greater (or Percona/MariaDB equivalent). This guide will use MySQL 8.0.x.
  • Web server software (Nginx, Apache). This guide will use Nginx.

Before you begin

Check the Ubuntu version.

lsb_release -ds
# Ubuntu 20.04 LTS

Create a new non-root user account with sudo access and switch to it.

adduser johndoe --gecos "John Doe"
usermod -aG sudo johndoe
su - johndoe

NOTE: Replace johndoe with your username.

Set up the timezone.

sudo dpkg-reconfigure tzdata

Ensure that your system is up to date.

sudo apt update && sudo apt upgrade -y

Install the needed packages.

sudo apt install -y zip unzip curl wget git

Install PHP

Install PHP, as well as the necessary PHP extensions.

sudo apt install -y php-cli php-fpm php-common php-mbstring php-curl php-gd php-mysql php-json

Check the version.

php -v
# PHP 7.4.3 (cli) (built: Mar 26 2020 20:24:23) ( NTS )
# Copyright (c) The PHP Group
# Zend Engine v3.4.0, Copyright (c) Zend Technologies
#    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

Check installed PHP extensions.

php -m

# mbstring
# curl
# gd
# PDO
# mysqli
# openssl
# . . .

Install MySQL

Install MySQL.

sudo apt install -y mysql-server

Check the version.

mysql --version
# mysql  Ver 8.0.19-0ubuntu4 for Linux on x86_64 ((Ubuntu))

Run the mysql_secure_installation script to improve the security of your MySQL installation.

sudo mysql_secure_installation

Log into MySQL as the root user.

sudo mysql -u root -p
# Enter password:

Create a new MySQL database and user and remember the credentials.

CREATE DATABASE dbname;
GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit;

Install Nginx

Install Nginx.

sudo apt install -y nginx

Check the version.

sudo nginx -v
# nginx version: nginx/1.17.10 (Ubuntu)

Configure Nginx for use with the Vanilla forum.

sudo vim /etc/nginx/sites-available/vanilla.conf

And populate the file with the below config.

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;
  }

}

Activate the new vanilla.conf configuration by linking the file to the sites-enabled directory.

sudo ln -s /etc/nginx/sites-available/vanilla.conf /etc/nginx/sites-enabled

Test the configuration.

sudo nginx -t

Reload Nginx.

sudo systemctl reload nginx.service

Install Vanilla forum

Navigate to the /var/www directory.

cd /var/www

Download the latest Vanilla forum.

sudo wget https://open.vanillaforums.com/get/vanilla-core-3.3

Unzip it and remove zip archive.

sudo unzip vanilla-core-3.3.zip
sudo rm vanilla-core-3.3.zip

Rename the directory to vanilla.

sudo mv package vanilla

Provide appropriate ownership.

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

Navigate to the folder where you uploaded Vanilla in your web browser and follow the instructions on the screen to complete the setup.