zoukankan      html  css  js  c++  java
  • nginx php-fpm安装手记

    首先下载nginx,nginx下载地址:http://www.nginx.org/download/nginx-0.8.53.tar.gz
    [root@winsyk ~]# mkdir -p /usr/src/nginx
    [root@winsyk ~]# cd /usr/src/nginx
    [root@winsyk ~]# wget -c http://www.nginx.org/download/nginx-0.8.53.tar.gz   #下载nginx
    [root@winsyk ~]# tar -zxvf nginx-0.8.53.tar.gz
    [root@winsyk ~]# cd nginx-0.8.53
    [root@winsyk ~]# useradd www   #添加www nginx运行账户
    [root@winsyk ~]# usemod -s /sbin/nologin -g www www #将www加入www组并禁止www登录shell
    编译前编辑src/core/nginx.h找到
    #define nginx_version
    #define NGINX_VERSION 
    #define NGINX_VER
    #define NGINX_VAR

    nginx php-fpm安装手记 - 无明 - 无明

    将上边信息替换为你想替换的信息,便于隐藏nginx版本。
    编辑src/http/ngx_http_special_response.c找到
    static u_char ngx_http_error_full_tail[] =
    static u_char ngx_http_error_tail[] =

    替换出错信息为你想隐藏的版本。
    [root@winsyk ~]# ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --without-http_rewrite_module --with-http_ssl_module --with-pcre && make && make install     
    注:运行编译,加入了--with-pcre参数便于nginx配置支持pcre正则库,编译完成,运行
    [root@winsyk ~]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf #启动nginx,nginx启动成功。

    二、安装php

    然后下载php,php下载地址为:http://cn.php.net/get/php-5.3.3.tar.bz2/from/this/mirror
    [root@winsyk ~]# mkdir -p /usr/src/nginx/php
    [root@winsyk ~]# wget -c http://cn.php.net/get/php-5.3.3.tar.bz2/from/this/mirror
    [root@winsyk ~]# tar -jxvf php-5.3.3.tar.bz2 #解压文件
    [root@winsyk ~]# yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel   #为了方面不编译这些文件,直接yum安装
    [root@winsyk ~]# ./configure --prefix=/usr/local/php --with-mysql --enable-fpm --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-debug --enable-safe-mode --enable-mbstring && make && make install  

    #编译php,--enable-fpm支持fpm/fastcgi编译需要一段时间(根据机器的性能来说)

    [root@winsyk ~]# cp -R ./sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf

    #复制php-fpm文件到php安装目录
    [root@winsyk ~]# cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm #php-fpm启动
    [root@winsyk ~]# /etc/init.d/php-fpm

    运行启动后,出现Nov 20 17:54:03.891754 [ALERT] [pool www]pm.min_spare_servers(0) must be a positive value 启动错误。
    编辑php-fpm.conf找到pm.min_spare_server ;pm.min_spare_servers = 5 去除;号
    也可使用sed -i 's/;pm.min_spare_servers/pm.min_spare_servers/g' /usr/local/php/etc/php-fpm.conf 进行替换
    再次运行php-fpm进行启动,提示错误:
    Nov 20 17:57:14.210553 [ALERT] [pool www] pm.max_spare_servers(0) must be a positive value
    sed -i 's/;pm.max_spare_servers = 35/pm.max_spare_servers = 35/g' /usr/local/php/etc/php-fpm.conf
    再次运行php-fpm启动,提示错误:
    Nov 20 17:58:55.248268 [WARNING] [pool www] pm.start_servers is not set. It's been set to 20
    sed -i 's/;pm.start_servers = 20/pm.start_servers = 20/g' /usr/local/php/etc/php-fpm.conf
    再次运行php-fpm未提示错误,启动成功。

    #配置php
    编译nginx.conf加入如下语句:
           location ~ .php$ {
            root html;   
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME   /usr/local/nginx/html$fastcgi_script_name;
            }
    echo "<?php phpinfo();?>" >/usr/local/nginx/html/index.php
    然后运行index.php测试安装成功。

  • 相关阅读:
    postgresql怎么导入数据库
    flask建表遇到的错误: flask,sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1071, 'Specified key was too long; max key length is 767 bytes')
    Linux(Ubuntu)系统下使用crontab定期执行任务
    Odoo中如何多workers中解决‘Bus.bus avriavle’
    python装饰器
    小程序开发可能会踩的坑
    Flask开发微信小程序后端基础知识准备
    Flask 中使用BluePrint蓝图分割业务代码,方便多人协作开发
    理解JWT(JSON Web Token)认证及python实践
    小程序中的数据请求sessionid,保持登陆状态。
  • 原文地址:https://www.cnblogs.com/xiaoleiel/p/8334688.html
Copyright © 2011-2022 走看看