How to install nginx, mysql, php (LEMP) on CentOS

How to install nginx, mysql, php (LEMP) on CentOS

Written by  Face4store

How to setup nginx, mysql, PHP (LEMP) on CentOS, this is article step by step to install on your system

1) Requirements:

First of all, make sure your CentOS has version 6.5 ( in this article I have to run in VMWare enviroment), check internet connection (sure) to install package.

$ ping www.google.com

unknown host www.google.com

If no internet connection, edit /etc/sysconfig/network-scripts/ifcfg-eth0 file and change value ONBOOT=yes

etc sysconfig network-scripts ifcfg-eth0

Start DHCP

$ dhclient -v eth0

 Start DHCP

Re-check with ipconfig command

ifconfig

2) Yum update

Before install LEMP (linux, nginx, mysql, php), recommend you to update yum, install wget if system does not have

$ yum update

$ yum install wget

yum install wget

3) Install repository

$ wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

$ rpm -Uvh remi-release-6.rpm epel-release-6-8.noarch.rpm

rpm -Uvh remi-release-6.rpm epel-release-6-8.noarch.rpm

 4) Setup mysql, mysql server

$ yum --enablerepo=remi,remi-test install mysql mysql-server

install mysql, mysql server

Start - restart mysql server: 

$ service mysqld restart

service mysqld restart

Configure mysql server

$ mysql_secure_installation

mysql secure installation

And press enter for none. Setup root password etc...

setting mysql root password

Service start on booting system

$ chkconfig mysqld on

5) Beign install php, nginx, php-common, php-fpm, php-pear, php-pdo, php-mysql, php-pgsql, php-pecl-memcache, php-gd, php-mbstring, php-mcrypt,  php-xml

$ yum --enablerepo=remi install nginx php php-fpm php-common

install nginx php php-fpm php-common
$ yum --enablerepo=remi install php-pear php-pdo php-mysql php-pgsql php-pecl-memcache php-gd php-mbstring php-mcrypt php-xml
install php-pear php-pdo php-mysql php-pgsql php-pecl-memcache php-gd php-mbstring php-mcrypt php-xml

6) Start- restart service nginx, php-fpm , service start when booting system

$ service nginx start

$ service php-fpm start

$ chkconfig nginx on

$ chkconfig php-fpm on

7) Open port 80 for HTTP:

$ vi /etc/sysconfig/iptables

/etc/sysconfig/iptables

Add line : -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

open port 80 nginx
Restart iptable
$ /etc/init.d/iptables restart
etc init.diptables restart
Done

We will have an article for adding new virtual host nginx as soon as posible, Face4store.com will discuss with you about this subject later.

Thank for your comment. 

Phuc Nguyen - Co-Founder

1 comment

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.