LNMP介绍
LNMP和LAMP应用场景相同,不同的就是web服务是由NGINX提供,并且php是作为一个独立服务存在的,这个服务叫做php-fpm
Nginx直接处理静态请求,动态请求会转发给php-fpm
LNMP工作原理
Nginx本身不会对PHP进行解析,终端对PHP过来页面请求会被Nginx交给FastCGI进程监听IP和端口,由php-fpm作为动态解析服务器处理,最后将处理结果再返回给nginx。其实,Nginx就是一个反向代理服务器。Nginx通过反向代理功能将动态请求转向后端php-fpm,从而实现对PHP的解析支持,这就是Nginx实现PHP动态解析的原理。
1:下载源码包
[root@ghs etc]# wget http://nginx.org/download/nginx-1.6.2.tar.gz
2:解压
[root@ghs tmp]# tar -zxvf nginx-1.6.2.tar.gz
3:编译Nginx环境
[root@ghs nginx-1.6.2]# ./configure --prefix=/usr/local/nginx --with-pcre
初始化中出现的错误
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
提示错误缺少pcre包
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
提示错误缺少zlib-devel包
解决方法
yum -y install pcre-devel zlib-devel
[root@ghs nginx-1.6.2]# make
[root@ghs nginx-1.6.2]# make install
4:设置环境变量
[root@ghs nginx-1.6.2]# vim /etc/profile.d/path.sh
#!/bin/bash
export PATH=$PATH:/usr/local/nginx/sbin
[root@ghs nginx-1.6.2]# source !$
5:启动nginx
[root@ghs nginx-1.6.2]# nginx
[root@ghs nginx-1.6.2]]# ps aux|grep nginx
root 16203 0.0 0.0 48960 3300 ? Ss Jun01 0:00 nginx: master process nginx
nobody 18542 0.0 0.2 74712 8324 ? S Aug26 22:44 nginx: worker process
nobody 18543 0.2 0.2 74720 8388 ? S Aug26 84:12 nginx: worker process
root 30071 0.0 0.0 112708 980 pts/0 R+ 15:33 0:00 grep --color=auto nginx
LNMP-安装Nginx
原文:https://www.cnblogs.com/douyi/p/11578695.html