How to Setup WordPress with Nginx and HHVM on Ubuntu 16.04

Alibaba Cloud
6 min readJun 25, 2018


By Hitesh Jethva, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

HHVM also known as HipHop Virtual Machine is an open source virtual machine developed by Facebook that can be used for executing programs written in Hack and PHP. HHVM uses a just-in-time compilation approach for performance reasons. HHVM is faster than the traditional PHP engine from ZEND, and is used by Facebook to serve billions of web requests per day.

In this tutorial, we will be going to explain how to install WordPress with Nginx, MariaDB, and HHVM on an Alibaba Cloud Elastic Compute Service (ECS) Ubuntu 16.04 instance.


  • A fresh Alibaba cloud instance with Ubuntu 16.04 server installed.
  • A static IP address is configured on the instance.
  • A root password is setup on the server.

Launch an Alibaba Cloud ECS Instance

First, login to your Alibaba Cloud ECS Console. Create a new ECS instance, with Ubuntu 16.04 as the operating system with at least 2GB RAM. Connect to your ECS instance and log in as the root user.

Once you are logged into your Ubuntu 16.04 instance, run the following command to update your base system with the latest available packages.

apt-get update -y

Install Nginx and MariaDB

First, you will need to install Nginx web server and MariaDB to your server. You can install them using the following command:

apt-get install nginx mariadb-server mariadb-client -y

Once both are installed, start Nginx and MariaDB service and enable them to start on boot time using the following command:

systemctl start nginx
systemctl enable nginx
systemctl start mariadb
systemctl enable mariadb

Configure MariaDB

By default, MariaDB installation is not secured, so you will need to secure it first. You can secure it by running the mysql_secure_installation script:


Answer all the questions as shown below:

Enter current password for root (enter for none): PRESS ENTER
Set root password? [Y/n] n
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

Once MariaDB is secured, log in to MariaDB shell using the following command:

mysql -u root -p

Enter your root password when prompt, then create a database for WordPress:

MariaDB [(none)]> create database wordpressdb;

Next, grant all privileges on wordpressdb using the following command:

MariaDB [(none)]> grant all privileges on wordpressdb.* to wordpress@localhost identified by 'password';

Next, flush the privileges with the following command:

MariaDB [(none)]> flush privileges;

Finally, exit from the MariaDB shell with the following command:

MariaDB [(none)]> exit;

Install and Configure HHVM

By default, HHVM is not available in Ubuntu 16.04 default repository. So you will need to add HHVM repository to your system. You can do this by running the following command:

apt-get install software-properties-common
apt-key adv --recv-keys --keyserver hkp:// 0x5a16e7281be7a449
add-apt-repository "deb $(lsb_release -sc) main"

Next, update the HHVM repository and install HHVM using the following command:

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

Once HHVM is installed, you should see the following output:

HHVM is installed.
The best way to get started is to use HHVM's built-in webserver:
$ hhvm -m server -p 8080
Running command-line scripts with HHVM requires no special setup:
$ hhvm whatever.php
FastCGI is also supported; see

Next, you will need to configure Nginx web server to use HHVM. You can do this with the following command:


You should see the following output:

[ ok ] Starting hhvm (via systemctl): hhvm.service.
Checking if Apache is installed
WARNING: Couldn't find Apache2 configuration paths, not configuring
Checking if Nginx is installed
Detected Nginx installation
Checking for custom Nginx configuration
Enabling hhvm Nginx module
Finished enabling module
Restarting Nginx

Next, start HHVM automatically on system startup using the following command:

update-rc.d hhvm defaults

Next, run the following command to use HHVM as a PHP alternative:

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

FInally, start HHVM service using the following command:

systemctl start hhvm

You can check the status of HHVM using the following command:

systemctl status hhvm


hhvm.service - LSB: Starts The HHVM FastCGI Daemon
Loaded: loaded (/etc/init.d/hhvm; bad; vendor preset: enabled)
Active: active (running) since Wed 2018-05-16 21:13:19 IST; 1min 14s ago
Docs: man:systemd-sysv-generator(8)
CGroup: /system.slice/hhvm.service
├─3365 /usr/bin/hhvm --config /etc/hhvm/php.ini --config /etc/hhvm/server.ini --user www-data --mode daemon -vPidFile=/var/run/hhvm/
├─3389 /usr/bin/hhvm --config /etc/hhvm/php.ini --config /etc/hhvm/server.ini --user www-data --mode daemon -vPidFile=/var/run/hhvm/
├─3390 sh -c /usr/bin/hh_single_compile -v Hack.Compiler.SourceMapping=1 --daemon
└─3392 /usr/bin/hh_single_compile -v Hack.Compiler.SourceMapping=1 --daemon
May 16 21:13:18 Node1 systemd[1]: Starting LSB: Starts The HHVM FastCGI Daemon...
May 16 21:13:19 Node1 systemd[1]: Started LSB: Starts The HHVM FastCGI Daemon.
May 16 21:14:29 Node1 systemd[1]: Started LSB: Starts The HHVM FastCGI Daemon.

Now, verify the PHP version with the following command:

php -v


HipHop VM 3.26.2 (rel)
Compiler: 1526415369_337251688
Repo schema: 7960f749dc8fba766d4ac967f6693b0ff0f1430b

Install WordPress

First, you will need to download the latest version of the WordPress from their official website. You can do this with the following command:


Once the download is completed, unzip the downloaded file with the following command:


Next. copy the extracted directory to the Nginx web root directory using the following command:

cp -r wordpress/* /var/www/html/

Next, change the directory to the /var/www/html/ and copy wordpress sample config file:

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

Next, open wp-config.php file and add database credentials which you have created earlier:

nano wp-config.php

Make the following changes:

/* The name of the database for WordPress /
define('DB_NAME', 'wordpressdb');
/* MySQL database username /
define('DB_USER', 'wordpress');
/* MySQL database password /
define('DB_PASSWORD', 'password');
/* MySQL hostname /
define('DB_HOST', 'localhost');

Save and close the file, then give proper permissions to WordPress:

chown -R www-data:www-data /var/www/html/
chmod -R 775 /var/www/html/

Finally, restart the Nginx and HHVM services.

systemctl restart nginx
systemctl restart hhvm

Access WordPress Web Installation Wizard

Now, open your web browser and type the URL http://your-server-ip/index.php, you will be redirected to the following page:

Here, choose the English language and click on the Continue button, you should see the following page:

Here, provide your Sitename, admin username and email address, then click on the Install WordPress button. Once WordPress is installed, you should see the following page:

Now, click on the Log In button, you will be redirected to the WordPress login page:

Now, provide your login credential and click on the Log In button, you should see the WordPress dashboard in the following image:

Related Alibaba Cloud Products

ApsaraDB for RDS is an on-demand database service that frees you up from the administrative task of managing a database, and leaves you with more time to focus on your core business. ApsaraDB for RDS is a ready-to-use service that is offered on MySQL, SQL Server and PostgreSQL. RDS handles routine database tasks such as provisioning, patch up, backup, recovery, failure detection and repair.
Distributed Relational Database Service is a lightweight (stateless), flexible, stable, and efficient middleware product independently developed by Alibaba Group to resolve scalability issues with single-host relational databases.
DRDS is primarily used for large-scale online data operations to operate, maintain and manage distributed databases throughout their entire lifecycle. Due to is compartmentalized structure, DRDS provides an efficient way to perform operations to meet the demand of the online services for relational databases.
Alibaba Cloud Virtual Private Cloud Alibaba Cloud VPC allows the flexibility to build your cloud architecture in a logically isolated and secure environment. This means users can control their virtual networking environment, including the selection of IP address range, the creation of subnets and configuration of route tables and network gateways. Users can also segregate VPC instances into different security domains using security group features.




Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website: