{"id":11740,"date":"2019-03-16T04:14:52","date_gmt":"2019-03-16T04:14:52","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11740"},"modified":"2019-03-16T04:14:52","modified_gmt":"2019-03-16T04:14:52","slug":"setting-up-high-performance-hhvm-and-nginx-apache-with-mariadb-on-debian-ubuntu","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/16\/setting-up-high-performance-hhvm-and-nginx-apache-with-mariadb-on-debian-ubuntu\/","title":{"rendered":"Setting Up High-Performance \u2018HHVM\u2019 and Nginx\/Apache with MariaDB on Debian\/Ubuntu"},"content":{"rendered":"<p><strong>HHVM<\/strong>\u00a0stands for\u00a0<strong>HipHop Virtual Machine<\/strong>, is an open source virtual machine created for running\u00a0<strong>Hack<\/strong>\u00a0(it\u2019s a programming language for HHVM) and\u00a0<strong>PHP<\/strong>\u00a0written applications. HHVM uses a last minute compilation path to achieve remarkable performance while keeping the flexibility that PHP programmers are addicted to. Till date, HHVM has achieved over a 9x increase in http request throughput and more than 5x cut in memory utilization (when running on low system memory) for\u00a0<strong>Facebook<\/strong>\u00a0compared with the PHP engine +\u00a0<a href=\"https:\/\/www.tecmint.com\/install-apc-alternative-php-cache-in-rhel-centos-fedora\/\" target=\"_blank\" rel=\"noopener\">APC (Alternative PHP Cache)<\/a>.<\/p>\n<p>HHVM can also be used along with a FastCGI-based web-server like\u00a0<strong>Nginx<\/strong>\u00a0or\u00a0<strong>Apache<\/strong>.<\/p>\n<div id=\"attachment_15480\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Install-HHVM-Nginx-Apache-MariaDB.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-15480\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Install-HHVM-Nginx-Apache-MariaDB-620x297.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Install-HHVM-Nginx-Apache-MariaDB-620x297.png 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Install-HHVM-Nginx-Apache-MariaDB.png 720w\" alt=\"Install HHVM, Nginx and Apache with MariaDB\" width=\"620\" height=\"297\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Install HHVM, Nginx and Apache with MariaDB<\/p>\n<\/div>\n<p>In this tutorial we shall look at steps for setting up\u00a0<strong>Nginx<\/strong>\/<strong>Apache<\/strong>\u00a0web server,\u00a0<strong>MariaDB<\/strong>\u00a0database server and\u00a0<strong>HHVM<\/strong>. For this setup, we will use\u00a0<strong>Ubuntu 15.04<\/strong>\u00a0(64-bit) as\u00a0<strong>HHVM<\/strong>\u00a0runs on 64-bit system only, although Debian and Linux Mint distributions are also supported.<\/p>\n<h3>Step 1: Installing Nginx and Apache Web Server<\/h3>\n<p><strong>1.<\/strong>\u00a0First do a system upgrade to update repository list with the help of following commands.<\/p>\n<pre># apt-get update &amp;&amp; apt-get upgrade\r\n<\/pre>\n<div id=\"attachment_15460\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/System-Upgrade.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-15460\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/System-Upgrade-620x344.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/System-Upgrade-620x344.png 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/System-Upgrade.png 720w\" alt=\"System Upgrade\" width=\"620\" height=\"344\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">System Upgrade<\/p>\n<p><strong>2.<\/strong>\u00a0As I said\u00a0<strong>HHVM<\/strong>\u00a0can be used with both\u00a0<strong>Nginx<\/strong>\u00a0and\u00a0<strong>Apache<\/strong>\u00a0web server. So, it\u2019s your choice which web server you will going to use, but here we will show you both web servers installation and how to use them with HHVM.<\/p>\n<h4>Installing Nginx<\/h4>\n<p>In this step, we will install\u00a0<strong>Nginx<\/strong>\/<strong>Apache<\/strong>\u00a0web server from the packages repository using following command.<\/p>\n<pre># apt-get install nginx\r\n<\/pre>\n<div id=\"attachment_15462\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Install-Nginx-Web-Server.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-15462\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Install-Nginx-Web-Server-620x344.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Install-Nginx-Web-Server-620x344.png 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Install-Nginx-Web-Server.png 720w\" alt=\"Install Nginx Web Server\" width=\"620\" height=\"344\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Install Nginx Web Server<\/p>\n<\/div>\n<h4>Installing Apache<\/h4>\n<pre># apt-get install apache2\r\n<\/pre>\n<div id=\"attachment_15472\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Install-Apache-Web-Server.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-15472\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Install-Apache-Web-Server-620x344.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Install-Apache-Web-Server-620x344.png 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Install-Apache-Web-Server.png 720w\" alt=\"Install Apache Web Server\" width=\"620\" height=\"344\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Install Apache Web Server<\/p>\n<\/div>\n<p>At this point, you should be able to navigate to following URL and you will able to see\u00a0<strong>Nginx<\/strong>\u00a0or\u00a0<strong>Apache<\/strong>\u00a0default page.<\/p>\n<pre>http:\/\/localhost\r\nOR\r\nhttp:\/\/IP-Address\r\n<\/pre>\n<h5>Nginx Default Page<\/h5>\n<div id=\"attachment_15467\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Nginx-Welcome-Page.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-15467\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Nginx-Welcome-Page-620x336.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Nginx-Welcome-Page-620x336.png 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Nginx-Welcome-Page.png 685w\" alt=\"Nginx Welcome Page\" width=\"620\" height=\"336\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Nginx Welcome Page<\/p>\n<\/div>\n<h5>Apache Default Page<\/h5>\n<div id=\"attachment_15473\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Apache-Default-Page.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-15473\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Apache-Default-Page-620x336.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Apache-Default-Page-620x336.png 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Apache-Default-Page.png 776w\" alt=\"Apache Default Page\" width=\"620\" height=\"336\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Apache Default Page<\/p>\n<\/div>\n<h3>Step 2: Install and Configure MariaDB<\/h3>\n<p><strong>3.<\/strong>\u00a0In this step, we will install\u00a0<strong>MariaDB<\/strong>, as it providers better performance as compared to\u00a0<strong>MySQL<\/strong>.<\/p>\n<pre># apt-get install mariadb-client mariadb-server\r\n<\/pre>\n<div id=\"attachment_15465\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Install-MariaDB-Database.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-15465\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Install-MariaDB-Database-620x344.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Install-MariaDB-Database-620x344.png 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Install-MariaDB-Database.png 720w\" alt=\"Install MariaDB Database\" width=\"620\" height=\"344\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Install MariaDB Database<\/p>\n<\/div>\n<p><strong>4.<\/strong>\u00a0After MariaDB successful installation, you can start MariaDB and set root password to secure the database:<\/p>\n<pre># systemctl start mysql\r\n# mysql_secure_installation\r\n<\/pre>\n<p>Answer the following questions by typing\u00a0<code>y<\/code>\u00a0or\u00a0<code>n<\/code>\u00a0and press enter. Make sure you read the instructions carefully before answering the questions.<\/p>\n<pre>Enter current password for root (enter for none) = <strong>press enter<\/strong>\r\nSet root password? [Y\/n] = <strong>y<\/strong>\r\nRemove anonymous users[y\/n] = <strong>y<\/strong>\r\nDisallow root login remotely[y\/n] = <strong>y<\/strong>\r\nRemove test database and access to it [y\/n] = <strong>y<\/strong>\r\nReload privileges tables now[y\/n] = <strong>y<\/strong> \r\n<\/pre>\n<p><strong>5.<\/strong>\u00a0After setting root password for MariaDB, you can connect to MariaDB prompt with the new root password.<\/p>\n<pre># mysql -u root -p\r\n<\/pre>\n<h3>Step 3: Installation of HHVM<\/h3>\n<p><strong>6.<\/strong>\u00a0At this stage we shall install and configure HHVM. You need to add the\u00a0<strong>HHVM<\/strong>\u00a0repository to your\u00a0<code>sources.list<\/code>\u00a0file and then you have to update your repository list using following series of commands.<\/p>\n<pre># wget -O - http:\/\/dl.hhvm.com\/conf\/hhvm.gpg.key | apt-key add -\r\n# echo deb http:\/\/dl.hhvm.com\/ubuntu <strong>DISTRIBUTION_VERSION<\/strong> main | sudo tee \/etc\/apt\/sources.list.d\/hhvm.list\r\n# apt-get update\r\n<\/pre>\n<p><strong>Important<\/strong>: Don\u2019t forget to replace\u00a0<strong>DISTRIBUTION_VERSION<\/strong>\u00a0with your\u00a0<strong>Ubuntu<\/strong>\u00a0distribution version (i.e. lucid, precise, or trusty.) and also on\u00a0<strong>Debian<\/strong>\u00a0replace with jessie or wheezy. On\u00a0<strong>Linux Mint<\/strong>\u00a0installation instructions are same, but petra is the only currently supported distribution.<\/p>\n<p>After adding HHVM repository, you can easily install it as shown.<\/p>\n<pre># apt-get install -y hhvm\r\n<\/pre>\n<p>Installing HHVM will start it up now, but it not configured to auto start at next system boot. To set auto start at next boot use the following command.<\/p>\n<pre># update-rc.d hhvm defaults\r\n<\/pre>\n<h3>Step 4: Configuring Nginx\/Apache to Talk to HHVM<\/h3>\n<p><strong>7.<\/strong>\u00a0Now, nginx\/apache and HHVM are installed and running as independent, so we need to configure both web servers to talk to each other. The crucial part is that we have to tell nginx\/apache to forward all PHP files to HHVM to execute.<\/p>\n<p>If you are using\u00a0<strong>Nginx<\/strong>, follow this instructions as explained..<\/p>\n<p>By default, the nginx configuration lives under\u00a0<strong>\/etc\/nginx\/sites-available\/default<\/strong>\u00a0and these config looks in\u00a0<strong>\/usr\/share\/nginx\/html<\/strong>\u00a0for files to execute, but it don\u2019t know what to do with PHP.<\/p>\n<p>To make Nginx to talk with HHVM, we need to run the following include script that will configure nginx correctly by placing a\u00a0<strong>hhvm.conf<\/strong>\u00a0at the beginning of the nginx config as mentioned above.<\/p>\n<p>This script makes the nginx to talk to any file that ends with\u00a0<strong>.hh<\/strong>\u00a0or\u00a0<strong>.php<\/strong>\u00a0and send it to HHVM via fastcgi.<\/p>\n<pre># \/usr\/share\/hhvm\/install_fastcgi.sh\r\n<\/pre>\n<div id=\"attachment_15468\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Configure-Nginx-for-HHVM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-15468\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Configure-Nginx-for-HHVM-620x344.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Configure-Nginx-for-HHVM-620x344.png 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Configure-Nginx-for-HHVM.png 720w\" alt=\"Configure Nginx for HHVM\" width=\"620\" height=\"344\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Configure Nginx for HHVM<\/p>\n<\/div>\n<p><strong>Important<\/strong>: If you are using Apache, there isn\u2019t any configuration is needed now.<\/p>\n<p><strong>8.<\/strong>\u00a0Next, you need to use\u00a0<strong>\/usr\/bin\/hhvm<\/strong>\u00a0to provide\u00a0<strong>\/usr\/bin\/php<\/strong>\u00a0(php) by running this command below.<\/p>\n<pre># \/usr\/bin\/update-alternatives --install \/usr\/bin\/php php \/usr\/bin\/hhvm 60\r\n<\/pre>\n<p>After all the above steps are done, you can now start\u00a0<strong>HHVM<\/strong>\u00a0and test it.<\/p>\n<pre># systemctl start hhvm\r\n<\/pre>\n<h3>Step 5: Testing HHVM with Nginx\/Apache<\/h3>\n<p><strong>9.<\/strong>\u00a0To verify that\u00a0<strong>hhvm<\/strong>\u00a0working, you need to create a\u00a0<strong>hello.php<\/strong>\u00a0file under nginx\/apache document root directory.<\/p>\n<pre># nano \/usr\/share\/nginx\/html\/hello.php       [For <strong>Nginx<\/strong>]\r\nOR\r\n# nano \/var\/www\/html\/hello.php               [For <strong>Nginx<\/strong> and <strong>Apache<\/strong>]\r\n<\/pre>\n<p>Add the following snippet to this file.<\/p>\n<pre>&lt;?php\r\nif (defined('HHVM_VERSION')) {\r\necho 'HHVM is working';\r\n phpinfo();\r\n}\r\nelse {\r\necho 'HHVM is not working';\r\n}\r\n?&gt;\r\n<\/pre>\n<p>and then navigate to the following URL and verify to see \u201c<strong>hello world<\/strong>\u201c.<\/p>\n<pre>http:\/\/localhost\/info.php\r\nOR\r\nhttp:\/\/IP-Address\/info.php\r\n<\/pre>\n<div id=\"attachment_15470\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/HHVM-Page.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-15470\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/HHVM-Page-620x436.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/HHVM-Page-620x436.png 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/HHVM-Page.png 820w\" alt=\"HHVM Page\" width=\"620\" height=\"436\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">HHVM Page<\/p>\n<\/div>\n<p>If \u201c<strong>HHVM<\/strong>\u201d page appears, then it means you\u2019re all set!<\/p>\n<h3>Conclusion<\/h3>\n<p>These steps are very easy to follow and hope your find this tutorial useful and if you get any error during installation of any packages, post a comment and we shall find solutions together. And any additional ideas are welcome.<\/p>\n<p><a style=\"font-size: 1rem;\" href=\"https:\/\/www.tecmint.com\/install-hhvm-and-nginx-apache-with-mariadb-on-debian-ubuntu\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>HHVM\u00a0stands for\u00a0HipHop Virtual Machine, is an open source virtual machine created for running\u00a0Hack\u00a0(it\u2019s a programming language for HHVM) and\u00a0PHP\u00a0written applications. HHVM uses a last minute compilation path to achieve remarkable performance while keeping the flexibility that PHP programmers are addicted to. Till date, HHVM has achieved over a 9x increase in http request throughput and &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/16\/setting-up-high-performance-hhvm-and-nginx-apache-with-mariadb-on-debian-ubuntu\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Setting Up High-Performance \u2018HHVM\u2019 and Nginx\/Apache with MariaDB on Debian\/Ubuntu&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11740","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11740","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11740"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11740\/revisions"}],"predecessor-version":[{"id":11741,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11740\/revisions\/11741"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}