一、LNMP安装实现CentOS 6.8
二、LNMP安装实现CentOS 7.3
三、编译安装实现

一、LNMP安装实现CentOS 6.8

前提:yum源配置有extra,base,epel等
[root@localhost php]# yum install nginx -y &> /dev/null && chkconfig nginx on && service nginx start
[root@localhost php]# curl http://127.0.0.1 -I //返回200表示访问正常

[root@localhost php]# rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
[root@localhost php]# yum install --enablerepo=webtatic install web56 web56-devel php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64 php56w-opcache.x86_64 -y
[root@localhost php]# yum install php56w-fpm
[root@localhost php]# chkconfig php-fpm && service php-fpm start
[root@localhost html]# vim /etc/php-fpm.d/www.conf //修改user和group为nginx
user = nginx
group = nginx
[root@localhost php]# netstat -tunlp |grep -i 9000 //验证是否php-fpm监听在9000端口

[root@localhost nginx]# vim /etc/nginx/conf.d/default.conf //假如是CentOS 7的话修改/etc/nginx/nginx.conf

server {
    listen       80 default_server;
    server_name  _;
    root         /usr/share/nginx/html;
    include /etc/nginx/default.d/*.conf;

    location / {
    }

    location ~ .*\.(php|php5)?$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi.conf;
    }
    ...  //省略error_page的内容
}

[root@localhost nginx]# nginx -t //检查语法
[root@localhost nginx]# service nginx restart

[root@localhost html]# vim /usr/share/nginx/html/info2.php

[root@localhost html]# yum install mysql-server -y &> /dev/null && chkconfig --add mysqld && service mysqld start
浏览器访问:http://192.168.2.111/info2.php //能够访问phpinfo的界面,代表nginx链接php-fpm正常
[root@localhost html]# cat info.php

备注:假如php不能链接mysql可以尝试查看php-fpm的log日志,默认/var/log/php-fpm/

二、LNMP安装实现CentOS 7.3

方法同CentOS6,但是
[root@localhost nginx]# vim /etc/nginx/nginx.conf
其他类似

三、编译安装实现

CentOS6上实现
https://www.cnblogs.com/hukey/p/5304437.html
CentOS7上实现
https://www.cnblogs.com/wujuntian/p/8183952.html

CentOS6 的yum安装参考:
https://www.cnblogs.com/hehongbin/articles/5741270.html