Configure a high-performance HHVM environment on Ubuntu

Source: Internet
Author: User
Tags hhvm nginx server linux mint

Configure a high-performance HHVM environment on Ubuntu
HHVM is called HipHop Virtual Machine. It is an open-source Virtual Machine used to run applications developed by Hack (a programming language) and php. With the high flexibility that PHP programmers are most concerned about, HHVM achieves remarkable performance by using the latest compilation methods. Up to now, compared with PHP + APC (Alternative PHP Cache), HHVM has improved FaceBook's HTTP request throughput by 9 times, in terms of memory usage, reduced memory usage by about 5 times. At the same time, HHVM can work with FastCGI-based Web servers (such as Nginx or Apache. Install HHVM, Nginx, Apache, and MariaDB. In this tutorial, We will configure Nginx/Apache web server, Database Server MariaDB, and HHVM together. We will use Ubuntu 15.04 (64-bit) Because HHVM can only run on 64-bit systems. This tutorial also applies to Debian and linux Mint. Step 1: Install Nginx or Apache Server 1. First, perform a system upgrade and update the software repository list, command # apt-get update & apt-get upgrade system upgrade 2. As I mentioned earlier, HHVM can be integrated with Nginx and Apache. Therefore, it is your freedom to use the server. However, we will teach you how to install the two servers. To install Nginx, run the following command to install the Nginx/Apache server # apt-get install nginx install the Nginx server install Apache # apt-get install apache2 install the Apache server, you can see the default Nginx or Apache page http: // localhost or http: // IP-Address through the following link. Step 2: install and configure MariaDB3, run the following command to install MariaDB, which is a database with better performance than mysql # apt-get install mariadb-client mariadb-server install MariaDB 4. After MariaDB is successfully installed, you can start it and set the root password to protect the database: # systemctl start mysql # mysql_se Cure_installation to answer the following questions, you only need to press y or n and press Enter. Please make sure that you have carefully read the instructions. Enter current password for root (enter for none) = press enterSet root password? [Y/n] = yRemove anonymous users [y/n] = yDisallow root login remotely [y/n] = yRemove test database and access to it [y/n] = yReload privileges tables now [y/n] = y5. After the password is set, you can log on to MariaDB. # Step 3 of mysql-u root-p: Install HHVM6. At this stage, we will install HHVM. We need to add the HHVM repository to your sources. list file, and then update the software list. # Wget-O-http://dl.hhvm.com/conf/hhvm.gpg.key | apt-key add-# echo deb http://dl.hhvm.com/ubuntu DISTRIBUTION_VERSION main | sudo tee/etc/apt/sources. list. d/hhvm. list # apt-get update important: do not forget to replace the preceding DISTRIBUTION_VERSION (for example, lucid, precise, trusty) with your Ubuntu release code, or Debian's jessie or wheezy. The same is true in Linux Mint, but only petra is supported. After the HHVM repository is added, you can easily install it. # Apt-get install-y hhvm can be started after it is installed, but it is not started. Run the following command to start the instance. # Update-rc.d hhvm defaults Step 4: Configure Nginx/Apache to connect HHVM7, now, nginx/apache and HHVM have been installed and run independently, therefore, we need to set them to associate them with each other. The key step is to inform nginx/apache to hand over all php files to HHVM for processing. If Nginx is used, follow the steps below: The nginx configuration file is in/etc/nginx/sites-available/default, these configuration files will be searched for execution in/usr/share/nginx/html. However, they do not know how to handle PHP. To ensure that Nginx can connect to HHVM, We need to execute the following script. It helps us to correctly configure Nginx and put hhvm. conf in the header of the configuration file nginx. conf mentioned above. This script ensures that Nginx can correctly process. hh and. php and send them to HHVM through fastcgi. #/Usr/share/hhvm/install_fastcgi.sh: it is important to configure Nginx and HHVM. If Apache is used, no configuration is required here. 8. Next, you need to use hhvm to provide the php runtime environment. #/Usr/bin/update-alternatives -- install/usr/bin/php/usr/bin/hhvm 60 after the above steps are completed, you can start and test it now. # Systemctl start hhvm Step 5: Test HHVM and Nginx/Apache9. To confirm whether hhvm is working, you need to create hello. php under the nginx/apache document root directory. # Nano/usr/share/nginx/html/hello. php [For Nginx] Or # nano/var/www/html/hello. php [adds the following code to the Nginx and Apache files: <? Phpif (defined ('hhvm _ version') {echo 'hhvm is working'; phpinfo ();} else {echo 'hhvm is not working';}?> Visit the following link to check whether you can see "hello world" http: // localhost/info. php or http: // IP-Address/info. if the "HHVM" page appears on the phpHHVM page, it means you have succeeded. Conclusion The above steps are very simple. I hope you will find this useful tutorial. If you encounter any problems in the above steps, leave us a comment, we will do our best to solve this problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.