zoukankan      html  css  js  c++  java
  • Nginx 1.9+PHP5.6 环境搭建

    1 PHP5.6
    
    1 下载安装包
    #wget http://mirrors.sohu.com/php/php-5.6.2.tar.gz
    #tar -zxf php-5.6.22 安装php依赖的包​​
    #yum install gcc gcc-c++ libxml2 libxml2-devel libjpeg-devel libpng-devel freetype-devel openssl-devel libcurl-devel libmcrypt-devel
    
    3 安装 (-prefix是安装目录,-with-mysql是mysql的安装目录,由于我是用yum装的,所以不需要写-with-mysql=****哪里这样子,其他参数自行百度。)
    #​./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --enable-pcntl --enable-mysqlnd --enable-opcache --enable-sockets --enable-sysvmsg --enable-sysvsem  --enable-sysvshm --enable-shmop --enable-zip --enable-ftp --enable-soap --enable-xml --enable-mbstring --disable-rpath --disable-debug --disable-fileinfo --with-mysql --with-mysqli --with-pdo-mysql --with-pcre-regex --with-iconv --with-zlib --with-mcrypt --with-gd --with-openssl --with-mhash --with-xmlrpc --with-curl --with-imap-ssl
    
    ​#make
    #make install
    
    若上几步都没报错的话就安装成功,有报错估计是少了点什么,用百度查查后yum一下吧。​
    #cp php.ini-production /usr/local/php/etc/php.ini​
    
    当我们使用nginx还要把php-fpm.conf放到/usr/local/php/etc/里头
    cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
    
    接下来我们还可能需要将php-fpm作为server服务
    ​#cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
    (/usr/local/src/php-5.6.17是PHP安装文件夹)​​
    设置权限,并添加服务
    #chmod +x /etc/init.d/php-fpm
    #chkconfig --add php-fpm
    以后可以使用如下命令管理php-fpm了
    #service php-fpm start
    #service php-fpm stop
    #service php-fpm restart
    #service php-fpm reload
    
    
    make: *** [sapi/cli/php] Error 1 解决办法
    
    ext/iconv/.libs/iconv.o: In function `php_iconv_stream_filter_ctor':
    /usr/local/php/ext/iconv/iconv.c:2491: undefined reference to `libiconv_open'
    collect2: ld returned 1 exit status
    make: *** [sapi/cli/php] Error 1# vi Makefile
     
    在安裝 PHP 到系统中时要是发生「undefined reference to libiconv_open'」之类的错误信息,那表示在「./configure 」沒抓好一些环境变数值。错误发生点在建立「-o sapi/cli/php」是出错,没給到要 link 的 iconv 函式库参数。 
    
    解决方法1:
    
    编辑Makefile 大约77 行左右的地方: EXTRA_LIBS = ..... -lcrypt 在最后加上 -liconv,例如: EXTRA_LIBS = ..... -lcrypt -liconv 然后重新再次 make 即可。
    
    解决方法2:
    make ZEND_EXTRA_LIBS='-liconv'
    ln -s /usr/local/lib/libiconv.so.2 /usr/lib64/
    
    configure: error: mcrypt.h not found. Please reinstall libmcrypt. 解决办法
    
    wget http://124.205.69.134/files/817400000026D1DF/soft.vpser.net/web/libmcrypt/libmcrypt-2.5.8.tar.gz
    ./configure
    make
    make install
    
    Don't know how to define struct flock on this system, set --enable-opcache=no 解决办法
    vim /etc/ld.so.conf.d/local.conf     # 编辑库文件
    /usr/local/lib                       # 添加该行
    :wq                                  # 保存退出
    ldconfig -v                          # 使之生效
    
    2 Nginx:
    
    
    wget http://nginx.org/download/nginx-1.9.7.tar.gz
    tar -zxvf nginx-1.9.7.tar.gz
    cd nginx-1.9.7
    ./configure --user=www --group=www --prefix=/usr/local/nginx-1.9.7 --with-http_stub_status_module 
    make;
    make install
    cd ..
    
    vi /usr/local/nginx/conf/nginx.conf
    ...
            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;
            }
    
    
    错误提示:
    ./configure: error: the HTTP rewrite module requires the PCRE library.
    安装pcre-devel解决问题
    yum -y install pcre-devel
    
    错误提示:
    ./configure: error: the HTTP cache module requires md5 functions
    from OpenSSL library.   You can either disable the module by using
    --without-http-cache option, or install the OpenSSL library into the system,
    or build the OpenSSL library statically from the source with nginx by using
    --with-http_ssl_module --with-openssl=<path> options.
     
    解决办法:
    yum -y install openssl openssl-devel
    
    3 环境变量:
    
    方法一:
    直接运行命令export PATH=$PATH:/usr/local/webserver/php/bin 和 export PATH=$PATH:/usr/local/webserver/mysql/bin
    使用这种方法,只会对当前会话有效,也就是说每当登出或注销系统以后,PATH 设置就会失效,只是临时生效。
    
    方法二:执行vi ~/.bash_profile修改文件中PATH一行,将/usr/local/webserver/php/bin 和 /usr/local/webserver/mysql/bin 加入到PATH=$PATH:$HOME/bin一行之后
    这种方法只对当前登录用户生效
    
    方法三:修改/etc/profile文件使其永久性生效,并对所有系统用户生效,在文件末尾加上如下两行代码
    PATH=$PATH:/usr/local/webserver/php/bin:/usr/local/webserver/mysql/bin
    export PATH
    最后:执行 命令source /etc/profile或 执行点命令 ./profile使其修改生效,执行完可通过echo $PATH命令查看是否添加成功。 
  • 相关阅读:
    C#反射的使用
    Swagger实例分享(VS+WebApi+Swashbuckle)
    WCF全双工通信实例分享(wsDualHttpBinding、netTcpBinding两种实现方式)
    WCF通信简单学习实例
    netcore 实现跨应用的分布式session
    netcore mvc 的简单实现
    netcore 基于 DispatchProxy 实现一个简单Rpc远程调用
    一步步到IOC
    《JavaScript设计模式与开发实践》读书笔记-基础知识
    windows下docker与.net core 的简单示例
  • 原文地址:https://www.cnblogs.com/chunguang/p/5904093.html
Copyright © 2011-2022 走看看