Setup HHVM + Nginx + MySQL on Ubuntu 14.04 & later system.

Just for a reminder, here are steps as a note to let anyone who wanna install HHVM + Nginx + MySQL on Google Cloud Platform (a.k.a GCP) like me.
So, here we go.

Step 1.
Before installation, we should shut down apache server, and then start installing Nginx server.

$sudo service apache2 stop

Start installing Nginx, and add it to boot automatically, and start it.

$sudo apt-get install nginx
$sudo update-rc.d nginx defaults
$sudo service nginx start

Start installing HHVM. HHVM is a virtual machine created by Facebook engineers. It is designed for high traffic request when you are using PHP as a server language. The biggest difference between HHVM PHP and other PHP servers is that HHVM compiles PHP code into machine code, that would make it faster for processing. You can refer the [HHVM] section in reference. I survey some other references, when you use HHVM, you will need more RAM and CPU for it. But I think that makes sense, cause it compiles PHP into machine code to get a better performance. Just like Android ART, it compiles Android APK into dex for machine code when you install your app, but the benefit is: it’s faster.

Add GnuPG public keys first.

$sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449

Add repo to source list. if you can’t run add-apt-repository, refer here.

$sudo add-apt-repository "deb http://dl.hhvm.com/ubuntu $(lsb_release -sc) main"

Update repo, install HHVM, and add it to boot automatically.

$sudo apt-get update
$sudo apt-get install hhvm
$sudo update-rc.d hhvm defaults

Now, cause you just installed Nginx server and HHVM, we need to use default HHVM configuration script to config HHVM into Nginx.

$sudo sh /usr/share/hhvm/install_fastcgi.sh

If you are curious what it does when you run the script, you can check the script code. Basically, it integrates the HHVM.conf into Nginx server default setting file. So, I will recommend you use a clean environment to install HHVM and Ngnix.

Install MySQL, MySQL server will bind to localhost (127.0.0.1)

$sudo apt-get install mysql-server

After installation, I will strongly recommend that you should harden your MySQL server by using “mysql_secure_installation” script.

$sudo mysql_secure_installation

When you finish all installation, you should be able to log in your MySQL.

$sudo mysql -u root -p

Reference:
[HHVM]
https://docs.hhvm.com/hhvm/getting-started/getting-started

[Install Ngnix & HHVM]
https://www.scalescale.com/tips/nginx/install-hhvm-and-nginx-on-ubuntu-14-04-lts/

[Linode]
https://www.linode.com/docs/databases/mysql/install-mysql-on-ubuntu-14-04

[Feature images]
https://www.ma-no.org/en/content/index_install-hhvm-nginx-on-ubuntu-14-04_2110.php

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s