Install WordPress with HHVM, Nginx and MariaDB on an Ubuntu 12.04 LTS


HipHopHHVM is an open-source virtual machine designed for executing programs written in PHP. HHVM stands for HipHop Virtual Machine and it was initially developed by Facebook to boost up their application performance, and for those who don’t know MariaDB is a drop-in replacement for MySQL. In this tutorial we will show you step by step how to install WordPress with HHVM, Nginx and MariaDB on an Ubuntu 12.04 LTS VPS.

Update the system and install necessary packages.

[email protected]:~# apt-get update && apt-get upgrade
[email protected]:~# apt-get install python-software-properties curl

Install MariaDB and create a database.

[email protected]:~# apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
[email protected]:~# add-apt-repository 'deb http://ftp.osuosl.org/pub/mariadb/repo/5.5/ubuntu precise main'
[email protected]:~# apt-get update
[email protected]:~# echo -e "Package: *\nPin: origin ftp.osuosl.org\nPin-Priority: 1000" | tee /etc/apt/preferences.d/mariadb
[email protected]:~# apt-get install mariadb-server
[email protected]:~# mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE wpdb;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON wpdb.* TO 'wpuser'@'localhost' IDENTIFIED BY 'wpuser_passwd';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q

Install and configure Nginx 1.4.x

[email protected]:~# add-apt-repository ppa:nginx/stable
[email protected]:~# apt-get install nginx

Set the worker_processes to the number of processors in your system.

To find out the number of processors in your system and set the worker_processes, run the following command:

[email protected]:~# sed -i "0,/^worker_processes/ s/^worker_processes .*$/worker_processes `grep -c processor /proc/cpuinfo`;/"  /etc/nginx/nginx.conf

Install hhvm and hhvm-fastcgi

[email protected]:~# apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 5A16E7281BE7A449
[email protected]:~# echo deb http://dl.hhvm.com/ubuntu precise main | tee /etc/apt/sources.list.d/hhvm.list
[email protected]:~# apt-get update
[email protected]:~# apt-get install hhvm-fastcgi

If you want to use php from the command line you will need to symlink php to hhvm

[email protected]:~# ln -s $(which hhvm) /usr/local/bin/php
[email protected]:~# php -v
HipHop VM v2.3.3 (rel)
Compiler: tags/HHVM-2.3.3-0-g4cf537888ba4ae253cc3dd0b04fe2c5bca5d24e4
Repo schema: 19f7626936db8612e50b3393be6e2cb7547771c8

Create a root directory for your website and download and extract WordPress

[email protected]:~# mkdir -p /var/www/yourwebsite.org/{public_html,logs}
[email protected]:~# wget -q -O - http://wordpress.org/latest.tar.gz | tar -xzf - --strip 1 -C /var/www/yourwebsite.org/public_html
[email protected]:~# chown www-data: -R /var/www/yourwebsite.org/public_html

Create a new Nginx server block

[email protected]:~# cat <<'EOF' > /etc/nginx/sites-available/yourwebsite.org
server {
  server_name yourwebsite.org;
  listen 80;
  root /var/www/yourwebsite.org/public_html;
  access_log /var/www/yourwebsite.org/logs/access.log;
  error_log /var/www/yourwebsite.org/logs/error.log;
  index index.php;

  location / {
    try_files $uri $uri/ /index.php?q=$uri&$args;
  }

  location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
    access_log off;
    expires max;
  }

  location ~ /\.ht {
    deny  all;
  }

  location ~ \.php$ {
    fastcgi_index index.php;
    fastcgi_keep_conn on;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}
EOF
[email protected]:~# ln -s /etc/nginx/sites-available/yourwebsite.org /etc/nginx/sites-enabled/yourwebsite.org
[email protected]:~# /etc/init.d/nginx restart

Set all services to start at boot

[email protected]:~# update-rc.d nginx defaults
[email protected]:~# update-rc.d hhvm-fastcgi defaults
[email protected]:~# update-rc.d mysql defaults

Finally, open your browser, type the address of your website and follow the on-screen instructions.

Of course, if you are one of our Linux VPS Hosting customers, you don’t have to do any of this, simply ask our admins, sit back and relax. Our admins will set this up for you immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Tutorials
How to Install Drupal 7 on CentOS 7 with Nginx, MariaDB and PHP-FPM
Tutorials
How to install OpenCart on a Linux Virtual Server
Tutorials
How to Speed Up WordPress with Redis Caching
  • Brian Lovett

    Thank you! I have spent two days trying to get HHVM running with Nginx on my centos 6 machine, and this tutorial did the trick.


 
Free Migration to RoseHosting. Award Winning Linux VPS Hosting with Fully Managed Support. Coupon RHBLOG50 for 50% offOrder Now
+