zoukankan      html  css  js  c++  java
  • Linux下搭建nginx php环境

    下载安装所需包

    openssl-1.0.1i.tar.gz

    zlib-1.2.8.tar.gz

    pcre-8.35.tar.gz

    nginx-1.7.4.tar.gz

    以上为nginx依赖文件

    libmcrypt-2.5.7.tar.gz

    php-5.3.28.tar.gz

    以上为php依赖文件

     

     

    依次安装

    1.安装openssl-1.0.1i.tar.gz

    [root@localhost mrms]# tar -zxvf openssl-1.0.1i.tar.gz
    
    [root@localhost mrms]# cd openssl-1.0.1i.tar.gz
    
    [root@localhost openssl-1.0.1i.tar.gz]# ./config 
    
    [root@localhost openssl-1.0.1i.tar.gz]# make && make install
    

    2.安装zlib-1.2.8.tar.gz

    [root@localhost mrms]# tar -zxvf zlib-1.2.8.tar.gz
    
    [root@localhost mrms]# cd zlib-1.2.8
    
    [root@localhost zlib-1.2.8]# ./configure 
    
    [root@localhost zlib-1.2.8]# make && make install

    3.安装pcre-8.35.tar.gz

    [root@localhost mrms]# tar -zxvf pcre-8.35.tar.gz
    
    [root@localhost mrms]# cd pcre-8.35
    
    [root@localhost pcre-8.35]# ./configure 
    
    [root@localhost pcre-8.35]# make && make install

     4.安装 nginx-1.7.4.tar.gz

    [root@localhost mrms]# tar -zxvf nginx-1.7.4.tar.gz
    
    [root@localhost mrms]# cd nginx-1.7.4
    
    [root@localhost nginx-1.7.4]# ./configure --with-pcre=../pcre-8.35 --with-zlib=../zlib-1.2.8 --with-openssl=../openssl-1.0.1i
    
    [root@localhost nginx-1.7.4]# make && make install
    

    至此Nginx的安装完成!

    第三步:检测是否安装成功

    [root@localhost nginx-1.2.6]# cd  /usr/local/nginx/sbin
    
    [root@localhost sbin]# ./nginx -t
    

    出现如下所示提示,表示安装成功

     

    启动nginx

    [root@localhost sbin]# ./nginx
    

    查看端口

    [root@localhost sbin]# netstat -ntlp
    

    结果如下

     

     

    接着安装libmcrypt-2.5.7.tar.gz, 这个文件是安装php所需

     

    注意:configure: error: mcrypt.h not found. Please reinstall libmcrypt.此错误由libmcrypt引起

    [root@localhost mrms]# tar -zxvf libmcrypt-2.5.7.tar.gz
    
    [root@localhost mrms]# cd libmcrypt-2.5.7
    
    [root@localhost libmcrypt-2.5.7]# ./configure 
    
    [root@localhost libmcrypt-2.5.7]# make && make install
    
    
    

    最后安装php

    [root@localhost mrms]# tar -zxvf php-5.3.28.tar.gz
    
    [root@localhost mrms]# cd php-5.3.28
    
    [root@localhost php-5.3.28]#./configure --prefix=/home/opt/php --with-config-file-path=/home/opt/php/etc --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --enable-mbstring --with-mcrypt --with-mhash --enable-fpm --with-gd --enable-gd-native-ttf --with-curl --with-openssl 
    [root@localhost php-5.3.28]# make && make install
    到此php就安装成功了,然后启动php-fpm就可以了。
    接下去就是配置nginx访问目录了,如出现php文件无法运行可以检查下fastcgi_param文件,我这里出现过一种这个情况,然后我在里面添加了fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;就OK了。
  • 相关阅读:
    这是另外一篇
    使用客户端写博客
    vim编码相关配置
    给eclipse装一些插件
    手机型号收集
    解决黑苹果与windows时区不一致
    记录一些在VPS上折腾的东西
    一个获取文件绝对路径的sh
    python批量GBK转UTF-8
    用NDK编译lua库
  • 原文地址:https://www.cnblogs.com/grimm/p/4995987.html
Copyright © 2011-2022 走看看