(一)安装nginx-1.6.3

1、安装nginx依赖包

mkdir -p /application
mkdir -p /home/oldboy/tools
yum install -y pcre pcre-devel  gcc-c++  openssl openssl-devel

2、下载安装并启动nginx 

useradd nginx -s /sbin/nologin  -M
cd /home/oldboy/tools/
wget http://nginx.org/download/nginx-1.6.3.tar.gz 
tar zxvf nginx-1.6.3.tar.gz
cd nginx-1.6.3
./configure --user=nginx --group=nginx --prefix=/application/nginx-1.6.3/ --with-http_stub_status_module  --with-http_ssl_module
make && make install   
ln -s /application/nginx-1.6.3 /application/nginx 
/application/nginx/sbin/nginx -t
/application/nginx/sbin/nginx
netstat -npult |grep nginx                                     
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      4432/nginx


(二) mysql安装在其它服务器上


(三) 安装PHP-5.5.26

1、安装php依赖包

yum -y install  zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel  freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel   zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel
cd /home/oldboy/tools/
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv && make && make install
cd ../
wget -O /etc/yum.repos.d/epel.repo  http://mirrors.aliyun.com/repo/epel-6.repo
yum -y install libmcrypt-devel mhash mcrypt

2、安装php

wget http://mirrors.sohu.com/php/php-5.5.32.tar.gz
tar zxvf php-5.5.32.tar.gz
cd php-5.5.32
 ./configure \
--prefix=/application/php5.5.32 \
--with-mysql=mysqlnd \
--with-mysqli \
--with-gettext \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-opcache=no  \
--enable-ftp

make && make install
cp php.ini-production /application/php5.5.32/lib/php.ini  
ln -s /application/php5.5.32/ /application/php

3、启动php

cd /application/php/etc/
cp php-fpm.conf.default php-fpm.conf
/application/php/sbin/php-fpm
netstat -npult |grep php-fpm
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      8020/php-fpm

4、为 Nginx 添加虚拟主机并整合php

cd /application/nginx/conf/
mv nginx.conf nginx.conf.bak
egrep -v "#|^$" nginx.conf.bak > nginx.conf 
sed -i  '10i\    include extra/*.conf;' nginx.conf 
mkdir extra
cd extra/

cat zabbix.conf 
 server {
        listen       80;
        server_name  zibbix.etiantian.org;
        location / {
            root   html/zibbix;
            index  index.php  index.html index.htm;
        }
        location ~ .*\.(php|php5)?$ {
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
        }
}

../../sbin/nginx -t

6、建立php测试页

<?php
phpinfo();
?>

7、建立mysql测试页

<?php
  $link_id=mysql_connect('mysql-server-ip','user','password') or mysql_error();
    if($link_id){
           echo "mysql is ok!";
     }
     else{
           echo mysql_error();
     }
?>

8、重启nginx并访问php测试页

/application/nginx/sbin/nginx -s reload
http://blog.etiantian.org/phpinfo.php


LNMP搭建完成



(四)安装zabbix-3.0.0