How to install nginx, mysql, php (LEMP) on CentOS
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
If no internet connection, edit /etc/sysconfig/network-scripts/ifcfg-eth0 file and change value ONBOOT=yes
Start DHCP
$ dhclient -v eth0
Re-check with ipconfig command
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
3) Install repository
$ 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
$ 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
Start - restart mysql server:
$ service mysqld restart
Configure mysql server
$ mysql_secure_installation
And press enter for none. Setup root password etc...
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
$ yum --enablerepo=remi 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
Add line : -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
Restart iptable
$ /etc/init.d/iptables 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.
1 comment
Thanks for the tutorial. I successfully installed LEMP on my CentOS 6 machine.
While searching around I found a script for installing Nginx, MySQL and PHP on CentoOS https://www.rosehosting.com/blog/install-centmin-mod-on-a-centos-6-vps . Have you tried this script?
Thanks again.