zoukankan      html  css  js  c++  java
  • Nginx配置

    环境问题
    Linux(centos6.6):
         Linux xiao-wei 2.6.32-504.16.2.el6.x86_64 #1 SMP Wed Apr 22 06:48:29 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
    Nginx:
         nginx version: nginx/1.8.0
    Mysql:
         mysql  Ver 14.14 Distrib 5.6.24, for Linux (x86_64) using  EditLine wrapper
    php:
         PHP 5.6.8 (cli) (built: Apr 30 2015 00:05:13) 
    Copyright (c) 1997-2015 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies


    注:安装过程參考下面文章

    一、安装准备:
    yum -y install gcc automake autoconf libtool make

    yum -y install gcc gcc-c++ glibc

    yum -y install libmcrypt-devel mhash-devel libxslt-devel
    libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel
    zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel
    ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel
    krb5 krb5-devel libidn libidn-devel openssl openssl-devel

    *此时会发现libmcrypt-devel mhash-devel没有安装(源没有发现该安装包!!_!!)
    採用源代码安装*(參考文章  http://www.cnblogs.com/huangzhen/archive/2012/09/12/2681861.html )

    源代码编译安装,去http://www.sourceforge.net下载Libmcrypt,mhash,mcrypt安装包 
    libmcrypt(libmcrypt-2.5.8.tar.gz );mcrypt(mcrypt-2.6.8.tar.gz ); mhash(mhash-0.9.9.9.tar.gz )

    2 .先安装Libmcrypt
    #tar -zxvf libmcrypt-2.5.8.tar.gz
    #cd libmcrypt-2.5.8
    #./configure
    #make
    #make install 说明:libmcript默认安装在/usr/local 

    3.安装mhash
    #tar -zxvf mhash-0.9.9.9.tar.gz
    #cd mhash-0.9.9.9
    #./configure
    #make
    #make install

    4.安装mcrypt
    #tar -zxvf mcrypt-2.6.8.tar.gz
    #cd mcrypt-2.6.8
    #LD_LIBRARY_PATH=/usr/local/lib ./configure
    #make
    #make install

    二、php-fpm安装

    wget http://cn2.php.net/distributions/ (注:这里须要找对应server下载对应版本号)
    tar zvxf php-5.6.24.tar.gz
    cd php-5.6.24
    ./configure --prefix=/usr/local/php  --enable-fpm --with-mcrypt
    --enable-mbstring --disable-pdo --with-curl --disable-debug  --disable-rpath
    --enable-inline-optimization --with-bz2  --with-zlib --enable-sockets
    --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex
    --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli
    --with-gd --with-jpeg-dir

    *出现checking for known struct flock definition... configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no错误*
    解决方法:(參考 http://blog.linuxeye.com/342.html )

    configure前执行export LD_LIBRARY_PATH=/lib/:/usr/lib/:/usr/local/lib

    make all install

    以上就完毕了php-fpm的安装。


    以下是对php-fpm执行用户进行设置
    #cd /usr/local/php
    #cp etc/php-fpm.conf.default etc/php-fpm.conf
    #vi etc/php-fpm.conf
    改动
    user = www-data
    group = www-data

    假设www-data用户不存在,那么先加入www-data用户
    #groupadd www-data
    #useradd -g www-data www-data

    三、编译安装nginx
    然后依照http://www.nginx.cn/install 安装nginx

    改动nginx.conf文件
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ .php$ {
    root html;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }

    四、创建php文件

    在/usr/local/nginx/html下创建index.php文件,输入例如以下内容

    <?php
        echo phpinfo();
    ?

    >



    五、启动服务

    启动php-fpm和nginx

    /usr/local/php/sbin/php-fpm 
    #手动打补丁的启动方式/usr/local/php/sbin/php-fpm start

    sudo /usr/local/nginx/nginx


    六、測试
  • 相关阅读:
    BZOJ 3881: [Coci2015]Divljak
    BZOJ 2434: [Noi2011]阿狸的打字机
    BZOJ 2580: [Usaco2012 Jan]Video Game
    BZOJ 3940: [Usaco2015 Feb]Censoring
    BZOJ 3942: [Usaco2015 Feb]Censoring
    PTA L2-002 链表去重 团体程序设计天梯赛-练习集
    PTA L2-001 紧急救援-最短路(Dijkstra)多条最短路找最优解并输出路径 团体程序设计天梯赛-练习集
    PTA L1-020 帅到没朋友 团体程序设计天梯赛-练习集
    Codeforces 429 B. Working out-dp( Codeforces Round #245 (Div. 1))
    HDU 6467.简单数学题-数学题 (“字节跳动-文远知行杯”广东工业大学第十四届程序设计竞赛)
  • 原文地址:https://www.cnblogs.com/zfyouxi/p/5147845.html
Copyright © 2011-2022 走看看