Deploying HHVM website environment (LEMH) in Ubuntu)

Source: Internet
Author: User
Tags fpm hhvm install php phpinfo

 

HHVM (HipHop Virtual Machine), a Virtual Machine environment developed by a famous FACEBOOK Company to execute PHP scripts, can greatly improve the performance of the PHP execution environment. Compared with our traditional website environment, the same hardware configuration can withstand more traffic access pressure from users, but we are not popular in China, and there are few tutorials for providing such installation environments, or we haven't paid much attention yet.

 

Some time ago some netizens mentioned whether they could provide these tutorials. After all, I have never installed or used the tutorials before, so I can only learn to use them now, there are few tutorials in China and abroad. This article describes how to build a LEMH environment in Ubuntu 14.04 and deploy the environment using Linux, Nginx, MariaDB, and HHVM.

 

1. Install Nginx

 

The code is as follows: Copy code

Apt-get update
Apt-get install nginx

 

 

During the installation process, enter y and press Enter. Then we can start nginx with service NGINX start to complete installation. Verify whether the installation is complete. Enter the IP address in the browser and you will see "Welcome to nginx on Debian! "No problem.

 

 

2. Install MariaDB

 

Over the years, we have been accustomed to using MYSQL databases when installing the website environment. After being acquired automatically, there is a problem of closed source security. Therefore, we are considering turning to MariaDB. The MariaDB management system is a branch of the MYSQL database. It is maintained mainly by the open-source community and has good compatibility with MYSQL. It can be said that MariaDB is also a good alternative to MYSQL.

 

If MYSQL has been installed on our server, delete it first and then install MariaDB.

 

The code is as follows: Copy code

Apt-get remove -- purge mysql-server mysql-client mysql-common
Apt-get autoremove
Rm-rf/var/lib/mysql
Apt-get autoclean

 

Add PPA

 

The code is as follows: Copy code

Apt-get install software-properties-common
Apt-key adv -- recv-keys -- keyserver hkp: // keyserver.ubuntu.com: 80 0xcbcb082a1bb943db
Add-apt-repository 'destroy http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu trusty main'
Apt-get update

 

Install MariaDB

 

The code is as follows: Copy code

Apt-get install mariadb-server

 

During execution, enter y and press enter to continue.

 

 

Enter the database ROOT password and press enter. After installation, run service mysql start to start the MYSQL database.

 

Third, install PHP and HHVM

 

HHVM is not used to replace PHP. It is an open-source PHP virtual machine that improves PHP performance. It adopts JIT compilation and has excellent performance. It is said that it is widely used by more and more people. We need to install PHP before installing HHVM.

 

The code is as follows: Copy code

Apt-get install php5-fpm php5-mysql php5-curl

 

Run the script and press enter y to continue. Then we install HHVM.

 

The code is as follows: Copy code

Wget-O-http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add-
Echo deb http://dl.hhvm.com/ubuntu trusty main | sudo tee/etc/apt/sources. list. d/hhvm. list
Apt-get update
Apt-get install hhvm

 

 

After installation, we need to execute a script to Configure NGINX.

 

The code is as follows: Copy code

Sh/usr/share/hhvm/install_fastcgi.sh

 

 

Restart HHVM.

 

The code is as follows: Copy code

Service hhvm restart

 

After the restart, we can test whether the installation of HHVM is complete.

 

The code is as follows: Copy code

Vi/var/www/html/phpinfo. php

 

Then add the script

 

 

After saving, enter http: // Our VPS host IP address/phpinfo. php in the address bar of the browser.

 

 

After seeing this, there will be no problem. HHVM installation is complete.

 

4. Configure HHVM + Nginx sites

 

After the environment is installed, we need to add domain names for site configuration.

 

1. Add a configuration file

 

The code is as follows: Copy code

Vi/etc/nginx/sites-available/my-site

 

Paste the following script

 

The code is as follows: Copy code

Server {
Listen 80;
Listen [:]: 80;

Root/var/www/html;

# Add index. php to the list if you are using PHP
Index index.html index.htm;

Server_name laozuo.org;
Include hhvm-with-fallback.conf;

Location /{
# First attempt to serve request as file, then
# As directory, then fall back to displaying a 404.
Try_files $ uri/= 404;
}

# Pass the PHP scripts to FastCGI server listening on Fig: 9000
#
Location @ fallback {
# Include snippets/fastcgi-php.conf;
#
# With php5-fpm:
Fastcgi_pass unix:/var/run/php5-fpm.sock;
Fastcgi_index index. php;
Include fastcgi_params;
}

# Deny access to. htaccess files, if Apache's document root
# Concurs with nginx's one
#
Location ~ /\. Ht {
Deny all;
}
}

 

We need to pay attention to the above two red labels, you need to modify the URL and file storage.

 

2. PHP5-FPM backup system

 

HHVM sometimes has a problem. In this case, we need to use a backup system. When HHVM fails, we take over with a PHP5-FPM. Therefore, we need to add the fallback configuration.

 

The code is as follows: Copy code

Vi/etc/nginx/hhvm-with-fallback.conf.

 

Then paste

 

The code is as follows: Copy code

Location ~ \. (Hh | php) $ {
Proxy_intercept_errors on;
Error_page 500 501 502 = @ fallback;

Fastcgi_keep_conn on;

Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
Include fastcgi_params;
}

 

Then save and exit.

 

3. Test NGINX

 

The code is as follows: Copy code

Nginx-t

 

 

4. Restart Nginx

 

The code is as follows: Copy code

Service nginx restart

 

Restart nginx to make NGINX take effect.

 

Summary: every time I write a tutorial, I started to use DEBIAN for testing. I found some problems, and then switched back to the UBUNTU system, it is also a great honor for me to learn more and learn from other users in the future. In this article, we can deploy LEMH (Linux, Nginx, MariaDB, HHVM) in the UBUNTU environment. If your site needs it, try it.

From: http://www.laozuo.org/6383.html

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.