How to Install WordPress with Nginx and HHVM Support on Ubuntu Linux

Laptop on table with keyboard and mouse
Laptop on table with keyboard and mouse

WordPress supports a variety of open-source tools and applications. For example, you can run WordPress with the support of the LAMP or LEMP stack.

This brief tutorial will show students and new users an easy way to install and run WordPress with HHVM ( Hip Hop Virtual Machine) support. Facebook developed HHVM to run applications based on PHP and the Hack language.

Most will agree that HHVM is faster than the traditional PHP stack. So, running it on HHVM, MarWordPress’ginx might help if you want to improve WordPress’ performance.

To get the setup correctly, follow the steps below:

Prepare Ubuntu Server

Before installing packages on Ubuntu systems, you must update and prepare the machine. Run the commands below to update and remove absolute packages from Ubuntu.

sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove

After running the command above, you may want to reboot depending on what was installed and upgraded.

Installing the Nginx web server

Once the Ubuntu machine is updated, run the commands below to install Nginx.

sudo apt-get install nginx

After installing Nginx, the commands below can be used to stop, start and enable Nginx.

sudo systemctl stop nginx.service
sudo systemctl start nginx.service
sudo systemctl enable nginx.service

Install MariaDB

After installing the Nginx web server, the next step will be to install the MariaDB database server. To do that, run the commands below.

sudo apt-get install mariadb-server mariadb-client

After installing MariaDB, the commands below can be used to manage the database server.

sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service

When you’re done running the commands above, r below to secure MariaDB and create the root password

sudo mysql_secure_installation

When prompted, use the guide below to answer the questions

Enter current password for root (enter for none): PRESS ENTER

Set root password? [Y/n] Y

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

Create WordPress Database

The next step is to create a database and database user for WordPress. To do that, we will create a WordPress database called wpdb and a user called wpuser.

To do that, run the command below to login into the MariaDB server

sudo mysql -u root -p

Then run the commands below to create a database called wpdb


Next, run the commands below to create a database user called wpuser


Grant all privileges to the user to manage wpdb

GRANT ALL PRIVILEGES ON wpdb.* to 'wpuser'@'localhost' IDENTIFIED BY 'new_password_here';

Finally, flush the permission to save your changes


Installing HHVM

To install HHVM on Ubuntu, you must add its repository and key. To do that, run the commands below to install the repository’s key.

wget -O - | sudo apt-key add -

Run the commands below to insrepository’sository

sudo sh -c "echo 'deb '$(lsb_release -cs)' main' > /etc/apt/sources.list.d/HHVM.list"

After that, run the commands below to install HHVM

sudo apt-get update
sudo apt-get install -y hhvm

Nginx, run the commands below to configure HHVM to work with the Nginx web server


Run the commands below to make HHVM the default PHP compiler

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

Finally, fun the commands below to start and enable HHVM

sudo systemctl start hhvn
sudo update-rc.d hhvm defaults

Configure Nginx and Install WordPress

Now that all the servers and modules are installed configure Nginx to serve PHP applications. To do that, open the Nginx default site configuration and add an index for PHP.

sudo nano /etc/nginx/sites-available/default

Then add the PHP index.

 # Add index.php to the list if you are using PHP
  index index.php index.html index.htm index.nginx-debian.html;

Save the file, and you’re done.

Download files

Now that you’ve all the servers and packages tyou’verdPress needs, it’s time to download WordPress content. To download the content, run the commands below.

cd /tmp/ && wget

Next, extract the downloaded content by running the commands below.

tar -xvzf latest.tar.gz

Configure WordPress Site

After extracting WordPress content, the first thing you’ll want to do is delete the Apache default. Instead, you’ll find its root directory.

sudo rm /var/www/html/index.nginx-debian.html

Next, move WordPress content to Apache2’s root directory by running the commands below.

sudo mv wordpress/* /var/www/html/

After moving WordPress content to its root directory, use the command below to make a copy of wp-config-sample.php file and name it wp-config.php.

The wp-config.php is the default configuration file for WordPress in its root folder.

sudo cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php

Next, edit the wp-config.php file and make the below changes.

sudo nano /var/www/html/wp-config.php

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘wpdb ‘);

/** MySQL database username’*/
def’ne’‘DB_ ‘SER’, ‘wpuser‘);

/** MySQL database passwo’d */
d’fi’e(‘DB_ ‘ASSWORD’, ‘new_password_here‘);

Save your changes when done.

Finally, run the commands below to set WordPress’s correct files and folder permissions to function correctly.

sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html/

After all of the above, restart the Apache2 web server.

sudo systemctl restart nginx.service

Start installation

The final step is to open your web browser and browse to the server IP address or hostname. Again, you should be prompted with the WordPress default setup page.


If you see this page, then everything went perfectly!

WordPress default setup page

Continue with the WordPress setup wizard until you’re done.

Posted by

I love computers; maybe way too much. What I learned I try to share at

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: