The LAMP stack consists of Linux, Apache2, MySQL (MariaDB) and PHP. It’s the most popular opensource stack that powers more than half of all websites online today.
Servers that make up the stack are inter-changeable. For example, Apache2 can be replaced with Nginx and MySQL replaced with MariaDB. For a while now, PHP had always been the member of the stack that couldn’t be changed easily.
Now it’s possible to replace PHP with another compiler. So, for those want to achieve optimal speed, they run a custom stack which includes Linux, Nginx, MariaDB and HHVM. Configuring these will allow optimal performance for your websites, blog or applications.
This brief tutorial is going to show you how to install and configure HHVM on Ubuntu 15.04.
To get started, add HHVM repository and its key to your server and install it from there. First run the commands below to add HHVM repository key to your server
sudo wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add -
Then run the commands below to add HHVM repository to your system
sudo echo deb http://dl.hhvm.com/ubuntu vivid main | sudo tee /etc/apt/sources.list.d/hhvm.list
Finally, run the commands below to update your system and install HHVM on Ubuntu 15.04.
sudo apt-get update && sudo apt-get install hhvm
After installing it, you’ll see a message that tells you HHVM is installed.
* HHVM is installed.
* Running PHP web scripts with HHVM is done by having your
* webserver talk to HHVM over FastCGI. Install nginx or Apache,
* and then:
* $ sudo /usr/share/hhvm/install_fastcgi.sh
* $ sudo /etc/init.d/hhvm restart
* (if using nginx) $ sudo /etc/init.d/nginx restart
* (if using apache) $ sudo /etc/init.d/apache restart
* Detailed FastCGI directions are online at:
* If you’re using HHVM to run web scripts, you probably want it
* to start at boot:
* $ sudo update-rc.d hhvm defaults
* Running command-line scripts with HHVM requires no special setup:
* $ hhvm whatever.php
* You can use HHVM for /usr/bin/php even if you have php-cli
* $ sudo /usr/bin/update-alternatives \
* –install /usr/bin/php php /usr/bin/hhvm 60
To allow Apache2 or Nginx web server to use HHVM, run the commands below.
After running the above command, HHVM searches your systems for available web server. It first looks for Apache2 and if Apache2 isn’t found, then it looks for Nginx. So the best method is to install the web server first before installing HHVM.
So, install Nginx, then run the commands above to enable HHVM module for Nginx.
If you want HHVM to automatically startup everytime your server starts, run the commands below.
sudo update-rc.d hhvm defaults
If PHP-Cli is installed, it could conflict with HHVM. To resolve that, run the commands below.
sudo /usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60
Finally, run the commands below to start up HHVM
systemctl start hhvm
To test HHVM, create a test page in the root directory and type these lines in the file and save it.
sudo vi /var/www/html/hhvminfo.php
Type these lines in the file and save it.
Next, browse to the server /hhvminfo.php and you’ll see the test page below.