微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

LNMP-安装Nginx

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  

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐