Install LEMP on Centos 6.4 64bit at Burst.Net VPS

It is a guide to install LEMP on a Centos 6.4 64bit VPS at It is also working on other VPS. LEMP stands for Linux, NginX, MySQL, PHP.

First of all, rebuild the OS on VPS with Centos-6.2-x86_64.

Other VPS providers have similar interface to rebuild / reload operation system.

After 5 to 10 minutes, the VPS is ready to use.

SSH to VPS through PUTTY with root account.  The following installation steps will be done in terminal window.

1) Update the system to Centos 6.4

yum update

There are 158 updates need to be installed. So just confirm it and wait all the updates completed. Then the Centos is updated from 6.2 to 6.4.

2) Install the required repositories

rpm -Uvh
rpm -Uvh

3) Install MySQL server

yum install mysql mysql-server

Start MySQL

/etc/init.d/mysqld restart

Configure MySQL server


It will guide you the whole procedure of steps to make the MySQL more security. It includes adding root password, remove sample database, remove anonymous user, disable root login remotely.

4) Install NginX

yum install nginx

Start nginx

/etc/init.d/nginx start

Check the IP address

ifconfig eth0 | grep inet | awk '{ print $2 }'


ifconfig venet0:0 | grep inet | awk '{ print $2 }'

5) Install PHP

The php-fpm package is located within the REMI repository, which, at this point, is disabled. The first thing we need to do is enable the REMI repository and install php and php-fpm:

yum --enablerepo=remi install php-fpm php-mysql

6) Configure PHP

vi /etc/php.ini

Find the line, cgi.fix_pathinfo=1, and change the 1 to 0.


7) Configure Nginx

vi /etc/nginx/nginx.conf

Raise the number of worker processes to 4 then save and exit that file. Actually, my VPS has one core only.

Now we should configure the nginx virtual hosts. In order to make the default nginx file more concise, the virtual host details are in a different location.

vi /etc/nginx/conf.d/default.conf

The configuration should be including following things. Make sure the server_name is changed to your domain or IP address.

# The default server
server {
listen       80 default_server;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {
root   /usr/share/nginx/html;
index  index.php index.html index.htm;

error_page  404              /404.html;
location = /404.html {
root   /usr/share/nginx/html;

# redirect server error pages to the static page /50x.html
error_page   500 502 503 504  /50x.html;
location = /50x.html {
root   /usr/share/nginx/html;

# proxy the PHP scripts to Apache listening on
#location ~ \.php$ {
#    proxy_pass;

# pass the PHP scripts to FastCGI server listening on
location ~ \.php$ {
root           /usr/share/nginx/html;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
include        fastcgi_params;

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#location ~ /\.ht {
#    deny  all;

Configure php-fpm configuration

vi /etc/php-fpm.d/www.conf

Replace apache by nginx

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;	will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx

Restart php-fmp

 service php-fpm restart

8) Add autostart services

sudo chkconfig --levels 235 mysqld on
sudo chkconfig --levels 235 nginx on
sudo chkconfig --levels 235 php-fpm on

8) Make a testing page with phpinfo() function and look at the following screenshots
NginX default page
PHP information page

There is one issue I have during installation. When I restart nginx, following error message shown:

 * Restarting nginx
 * Stopping nginx nginx
 * Starting nginx nginx
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

After do a little bit research, I found it is because of the port 80 is used by others. So I found it is Apache, another web server is running already.
I enter the command to remove Apache

yum remove httpd