How to install Wordpress with Nginx, MariaDB and HHVM on Debian 8

HHVM (Hip Hop Virtual Machine) is a just-in-time compiler developed by Facebook to run applications that are written in PHP and Hack language. HHVM is faster than the traditional PHP engine from ZEND and is used by Facebook to serve billions of web requests per day. HHVM has a 9x higher throughput of web requests and over a 5x reduction in memory consumption compared with the Zend PHP 5.2 engine + APC. see more here.

This tutorial describes the installation of Nginx, MariaDB, HHVM and Wordpress on Debian 8 (Jessie).

1 Prerequisites

The server should run a Debian 8 (64Bit) minimal server install. If you install the server from scratch, then take a look at this guide to get a clean minimal install. I will use the IP as my server IP. Please replace this IP with your server IP in all commands where it appears.

2 Install Nginx

The Nginx package is available in the Debian apt repository. Nginx can be installed with the following command:

apt-get update
apt-get install nginx unzip

Restart Nginx when the installation is completed.

systemctl start nginx

Now you can test Nginx in your browser to see if it is installed properly. Open the server IP: You should see a page similar to the one below.

3 Install and Configure MariaDB

I will install MariaDB instead of MySQL to take advantage of its better performance and additional functions. MariaDB is a fork of the MySQL Database Server maintained by the original MySQL Developers.

To install MariaDB, run the following apt-get command:

apt-get install mariadb-client mariadb-server

And start MariaDB with systemctl:

systemctl start mysql

Now login to MariaDB with the "mysql" command, the command will request the password that you have set during MariaDB install above.

mysql -u root -p


The next step is to create a new database with the name wordpressdb and new database user with the name wpuser for the WordPress installation. Execute the commands below inside the MySQL prompt to achieve that. Replace the password 'wpuser@' with a secure password that will be used as password for the new WordPress database.

create database wordpressdb;
create user wpuser@localhost identified by 'wpuser@';
grant all privileges on wordpressdb.* to wpuser@localhost identified by 'wpuser@';
flush privileges;

Create Wordpress Database

4 Install and Configure HHVM

Add the repository from to the Ubuntu repository file /etc/apt/sources.list and update the repository:

wget -O - | apt-key add -
echo deb jessie main | tee /etc/apt/sources.list.d/hhvm.list
apt-get update

Then install the HHVM package:

apt-get install hhvm

HHVM comes with a script to connect Nginx with HHVM. Run the command below:


Configure HHVM to start automatically when the server boots:

update-rc.d hhvm defaults

HHVM shall be used for /usr/bin/php even if you have php-cli installed, so we run the Debian update-alternatives script to reconfigure the default PHP:

/usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60

Then start HHVM with systemctl:

systemctl start hhvm

In the next step, I will test if HHVM is used to parse PHP pages in Nginx and on the shell.

Create new file with the name info.php in the directory /var/www/html/:

cd /var/www/html/
nano info.php

And add this PHP code into the file:

echo 'HipHop';

Now access the file in your browser: When you see the word HipHop in your web page, then HHVM is working correctly.

Finally test HHVM in your server console/terminal, type this command:

php info.php
php -v

The first command shall show the word "HipHop", the second command the HHVM version.

rm /var/www/html/info.php

5 Install Wordpress

Enter the /var/www/html/ folder, download WordPress and extract the archive:

cd /var/www/html/

The unzip command extracts Wordpress into the "wordpress" sub-directory, I will move all WordPress files and directories to /var/www/html/ as I like to access wordpress on / on the server and not on /wordpress/:

cd /var/www/html/
mv wordpress/* .
rm -rf wordpress/

Then change the owner of the WordPress files to the user and group www-data. Normally, all files in the /var/www/html/ directory are owned by the www-data user and group.

find . -type d -exec chown www-data:www-data {} \;
find . -type f -exec chown www-data:www-data {} \;

Rename the file wp-config-sample.php to wp-config.php. Then open the file with the nano editor and set the database name, user and password that was created during the database setup.

mv wp-config-sample.php wp-config.php
nano wp-config.php
DB_NAME = wordpressdb
DB_USER = wpuser
DB_PASSWORD = wpuser@

Now edit the nginx virtualhost file /etc/nginx/sites-available/default, and add index.php  as the first item of the index config setting. This setting instructs Nginx to use the index.php file as the standard index file when the website is accessed with / (without a file name).

rm -f index.nginx.html
nano /etc/nginx/sites-available/default

Then restart Nginx:

systemctl restart nginx

Try to access server IP: again, you will be redirected to the WordPress installer. Follow the instructions of the installer to finish the installatiom.

1) Please choose your language, example: English(United States) and press the button Continue.

Wordpress: Select the language.

2) Fill in the username and password that shall be used to authenticate the WordPress administrator and your email address, then press the Install Wordpress button.

Wordpress: Login details.

Wait until the installation is finished, then go to the WordPress administrator Login:, or visit WordPress home page

Wordpress: Installation finished.

Wordpress admin login.

Wordpress is now installed with HHVM and Nginx on your Debian 8 server.

6 Conclusion

The setup described in this tutorial combines some of the fastest software options to run a Wordpress site. Nginx is a widely used high-performance web server that is able to serve pages faster than the traditional Apache web server, HHVM is a high-speed replacement for the PHP Zend engine to run PHP scripts and MariaDB is a very fast MySQL replacement.

This tutorial is based on the Howtoforge tutorial from Muhammed Arul for Ubuntu 15.04.

Share this page:

9 Comment(s)