编译安装LNMP(Redhat5.4+nginx(3)

安装PHP-5.3.6
    1、 准备如下扩展包: 
       libevent-1.4.14b-stable.tar.gz  //扩展系统中的事件处理机制
       libiconv-1.13.1.tar.gz     //扩展系统的字符编码支持
       libmcrypt-2.5.8.tar.gz    //扩展系统加密功能
       mhash-0.9.9.9.tar.bz2 //扩展系统单向加密算法功能
       分别安装以上扩展包:
      # tar zxvf libevent-1.4.14b-stable.tar.gz
        # cd libevent-1.4.14b-stable
        # ./configure
        # make && make install
        # make verify
       
      # tar zxvf libiconv-1.13.1.tar.gz
        # cd libiconv-1.13.1
        # ./configure
        # make && make install
       
        # tar zxvf libmcrypt-2.5.8.tar.gz
        # ./configure
        # make && make install
        # ldconfig -v
        # cd libltdl
        # ./configure --with-gmetad --enable-gexec --enable-ltdl-install
        # make && make install
       
        # tar jxvf mhash-0.9.9.9.tar.bz2
        # cd mhash-0.9.9.9
        # ./configure
        # make && make install


        # ln -sv /usr/local/lib/libmcrypt* /usr/lib/
        # ln -sv /usr/local/lib/libmhash.* /usr/lib/
    2、安装php-5.3.6
     # tar jxvf php-5.3.6.tar.bz2
     # cd jxvf php-5.3.6
     # ./configure --prefix=/usr/local/php --with-MySQL=/usr/local/mysql --with-openssl --enable-fpm --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-libxml-dir=/usr --enable-xml  --with-mhash --with-mcrypt  --with-config-file-path=/etc/php --with-config-file-scan-dir=/etc/php --with-bz2 --with-curl
      在“./configure”编译选项中,指定将PHP安装到/usr/local/php下,“--enable-fpm”是激活对FastCGI模式的fpm支持。
     
       为php准备配置文件
     # cp php.ini-production /usr/local/php/etc/php.ini
      
       为fastcgi准备服务脚本
      # cp sapi/fpm/init.d.php-fpm  /etc/rc.d/init.d/php-fpm
    
       启动fastcgi:
     # cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
      # vim /usr/local/php/etc/php-fpm.conf
       启用如下选项:
       pm.max_children = 50
       pm.start_servers = 5
       pm.min_spare_servers = 2
       pm.max_spare_servers = 8
       pid = run/php-fpm.pid
 
  接下来整合nginx和php5


   编辑/etc/nginx/nginx.conf,启用如下选项:
    location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }


   导入FCGI的配置到一个单个文件中,
    vim /etc/nginx/fastcgi_params
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;


  并在所支持的主页面格式中添加php格式的主页,类似如下:
   location / {
            root   html;
            index  index.php index.html index.htm;
        }
       
而后重启nginx
# service nginx restart
#service php-fpm restart
  
至此LNMP就算部署完成了,可以提供一个测试页面验证是否能工作:

vim /usr/html/index.php

<?php
    phpinfo();
    ?>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/264efde1a974595ed6ca4c70d9da0e26.html