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 '[email protected]' with a secure password that will be used as password for the new WordPress database.

create database wordpressdb;
create user [email protected] identified by '[email protected]';
grant all privileges on wordpressdb.* to [email protected] identified by '[email protected]';
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 = [email protected]

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:

Suggested articles

9 Comment(s)

Add comment


By: Mf

how. EXACTLY, do you modify this procedure to make wordpress work in subfolders, e.g. and/or with seo-friendly urls like myblog/2015/06/hello-world ? Thx

By: Rafael Rios Saavedra

Just a few comments:

  - After installing hhvm you must restart nginx to nginx know about hhvm

  - A shoter way of changing permisions is :  chown -R www-data: *

  - It is not necesary to edit wp-config.php by hand, once uncompressed and fixed permissions you can go to the browser and configure those parameter via web.


just my 2cents.

By: Rafael Rios Saavedra

@Mf, that is called "permalinks" in wordpress jargon.

Here is how to configure it: Permalinks

By: scotty581

 I have downloaded the virtual machine from this tutorial and updated the ip address, but whenever I try to access the site the page doesnt load correctly and I can see the site still trying to call the old ip address of   Any idea what else I need to change in the VM?

Here is a screenshot:

By: till

Change the IP in the /etc/hosts file as well. Then Login to the WordPress admin and update the website details to match your domain name before you try to access the WordPress frontend.

By: crossifixio

 many thanks! I followed another tutorial 4-5 months or so ago and for some reason it was a headache. You made it so easy. Thank you!

By: Alexander

Hello! All installation process was fine. Wordpress was stand good but in few minutes after that there is "502 bad gateway" begun to show. After reboot VPS it works during a minute, and then "502" again. Do you know how to fix it?

Thanks beforehand!

By: The.free87

And how about the mail server,.? Roundcube especially,.. thanks

By: Fabio


When I go to the browser instead of the info.php page, it asks to download the file, can you help me?