一,LNMP概述

      LNMP代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构。

      Linux是一类Unix计算机操作系统的统称,是目前最流行的免费操作系统。代表版本有:debian、centos、ubuntu、fedora、gentoo等。

Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP代理服务器。

Mysql是一个小型关系型数据库管理系统。

     PHP是一种在服务器端执行的嵌入HTML文档的脚本语言。

这四种软件均为免费开源软件,组合到一起,成为一个免费、高效、扩展性强的网站服务系统。

编辑本段特点 Nginx是一个小巧而高效的Linux下的Web服务器软件,是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler 站点开发的,已经在一些俄罗斯的大型网站上运行多年,相当的稳定。

Nginx性能稳定、功能丰富、运维简单、处理静态文件速度快且消耗系统资源极少。

编辑本段

优点 作为 Web 服务器:相比 Apache,Nginx 使用更少的资源,支持更多的并发连接,体现更高的效率。

作为负载均衡服务器:Nginx 既可以在内部直接支持 Rails 和 PHP,也可以支持作为 HTTP代理服务器对外进行服务。Nginx 用C编写,不论是系统资源开销还是CPU使用效率都比Perlbal要好的多。

作为邮件代理服务器:Nginx同时也是一个非常优秀的邮件代理服务器(最早开发这个产品的目的之一也是作为邮件代理服务器),Last/fm 描述了成功并且美妙的使用经验。

Nginx 安装非常的简单,配置文件非常简洁(还能够支持perl语法)。Nginx支持平滑加载新的配置,还能够在不间断服务的情况下进行软件版本的升级。

二,LNMP环境的搭建

     php,mysql环境的搭建详见本人博客其他内容

     nginx环境的建立

[root@station2 ~]# mkdir /mnt/cdrom
[root@station2 ~]# mount /dev/cdrom /mnt/cdrom/建立光盘挂载点
[root@station2 ~]# yum install pcre-devel.i386
安装成功
库文件提高网站性能
[root@station2 ~]# tar -zxvf libevent-2.0.16-stable.tar.gz -C /usr/local/src/
[root@station2 ~]# cd /usr/local/
[root@station2 local]# vim /etc/ld.so.conf.d/libevent.conf
2012-08-31_121023
[root@station2 local]# cd /usr/local/src/
[root@station2 src]# cd libevent-2.0.16-stable/
[root@station2 libevent-2.0.16-stable]# ./configure
[root@station2 libevent-2.0.16-stable]# make
[root@station2 libevent-2.0.16-stable]# make install
手动加载
[root@station2 libevent-2.0.16-stable]# ldconfig -v
[root@station2 libevent-2.0.16-stable]# ldconfig -pv |grep libevent

2012-08-31_121756 解压liginx
[root@station2 ~]# tar -zxvf nginx-1.0.11.tar.gz -C /usr/local/src/
[root@station2 ~]# cd /usr/local/src/
[root@station2 src]# cd nginx-1.0.11/
[root@station2 nginx-1.0.11]# cd ..
[root@station2 src]# cd libevent-2.0.16-stable/
[root@station2 libevent-2.0.16-stable]# groupadd  -r  nginx
[root@station2 libevent-2.0.16-stable]# useradd -r -g nginx -s /bin/false  -M nginx
[root@station2 ~]# cd /usr/local/src/
[root@station2 src]# cd nginx-1.0.11/
[root@station2 nginx-1.0.11]# ./configure \
> --prefix=/usr \
>  --sbin-path=/usr/sbin/nginx \
>  --conf-path=/etc/nginx/nginx.conf \
>  --error-log-path=/var/log/nginx/error.log \
>  --http-log-path=/var/log/nginx/access.log \
>  --pid-path=/var/run/nginx/nginx.pid \
>  --lock-path=/var/lock/nginx.lock \
>  --user=nginx \
>  --group=nginx \
>  --with-http_ssl_module \
>  --with-http_flv_module \
>  --with-http_stub_status_module \
>  --with-http_gzip_static_module \
> --http-client-body-temp-path=/var/tmp/nginx/client/ \
>  --http-proxy-temp-path=/var/tmp/nginx/proxy/ \
>  --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
>  --with-pcre
[root@station2 nginx-1.0.11]# make
[root@station2 nginx-1.0.11]# make install
[root@station2 ~]# mkdir -pv /var/tmp/nginx
[root@station2 ~]# nginx

测试图
2012-08-31_131155

使Nginx和Php、Mysql进行关联

[root@station2 ~]# vim /etc/nginx/nginx.conf
2012-08-31_132820

原装

新加的
[root@station2 ~]#vim /usr/local/src/nginx/fastcgi_params

第七哈 

此处红线盖着下划线

[root@station2 ~]# pkill -1 nginx

[root@station2 ~]# cd /usr/local/src/nginx-1.0.11/html

[root@station2 html]#mv index.html index.php 

[root@station2 html]#vim index.php

2012-09-01_223448

[root@lyt php-5.3.7]# cp php.ini-production /usr/local/php/etc/php.ini

为php-fpm提供配置文件

[root@localhost php-5.3.7]# cp /usr/local/php/etc/php-fpm.conf.default
/usr/local/php/etc/php-fpm.conf

[root@localhost php-5.3.7]# cd /usr/local/php/etc/

[root@localhost etc]# vim php-fpm.conf // 编辑该文件去掉分号

error_log=

pm.max_children =

pm.start_servers =

pm.min_spare_servers =

pm.max_spare_servers =

pm.max_requests =

[root@localhost etc]# /usr/local/php/sbin/php-fpm & //启动fastcgi

测试

2012-09-01_223433

[root@station2 html]#vim index.php

2012-09-01_223505

2012-09-01_225519