• Nginx和php-fpm部署到不同的服务器


    Nginx安装滤过,基本上nginx上的配置很少,只要添加个server就可以了,主要安装php-fpm服务

    php7.1.3安装

    1、安装依赖的软件包
    yum -y install gcc gcc-c++ autoconf automake libtool re2c flex bison php-mcrypt libmcrypt libmcrypt-devel openssl-devel libxml2-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel zlib-devel mcrypt bzip2-devel libicu-devel systemd-devel mhash postgresql-devel glibc-devel glib2-devel ncurses-devel curl-devel gettext-devel lrzsz net-tools make vim
    2、添加php用户
    groupadd php
    useradd -M -s /sbin/nologin -g php php
    3、解压源码文件:
    tar php-7.1.3.tar.gz
    4、编译安装php
    cd php-7.1.3
    ./buildconf --force

    ./configure --prefix=/usr/local/php-7.1.3 --with-config-file-path=/usr/local/php-7.1.3/etc/ --with-mysql-sock=/var/lib/mysql/mysql.sock --with-mcrypt --with-mhash --with-openssl --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --with-xmlrpc --with-libdir=/usr/lib64 --with-png-dir=/usr/lib64 --with-gettext=/usr/lib64 --with-curl --with-jpeg-dir --with-freetype-dir=/usr/lib64 --with-fpm-user=php --with-fpm-group=php --with-pgsql --with-libxml-dir --with-bz2 --with-pcre-dir --without-gdbm --without-pear --enable-zip --enable-inline-optimization --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-intl --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --enable-soap --enable-session --enable-opcache --enable-fpm --enable-fileinfo --enable-calendar --enable-cli --enable-static --enable-wddx --disable-debug --enable-mysqlnd --enable-pdo --disable-rpath

    make install
    5、copy配置文件
    cp php.ini-development /usr/local/php-7.1.3/etc/php.ini
    cp /usr/local/php-7.1.3/etc/php-fpm.conf.default /usr/local/php-7.1.3/etc/php-fpm.conf
    cp /usr/local/php-7.1.3/etc/php-fpm.d/www.conf.default /usr/local/php-7.1.3/etc/php-fpm.d/www.conf
    cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
    chmod +x /etc/init.d/php-fpm
    6、编辑配置文件
    vim /usr/local/php-7.1.3/etc/php-fpm.d/www.conf

    [global]
    pid = /usr/local/php-7.1.3/var/run/php-fpm.pid
    error_log = /usr/local/php-7.1.3/var/log/php-fpm.log
    [php]
    listen = 0.0.0.0:9002
    listen.allowed_clients = 192.168.1.251 #Nginx服务器的ip地址
    user = php
    group = php
    pm = dynamic
    pm.max_children = 50
    pm.start_servers = 20
    pm.min_spare_servers = 5
    pm.max_spare_servers = 35
    pm.max_requests = 500
    rlimit_files = 1024
    slowlog = /tmp/phpslow.log
    request_slowlog_timeout = 1

    7、编辑Nginx的配置文件

    server {
            listen       80;
            server_tokens off;
            server_name ServerName;
    
            location ~ .php$ {
                root        /opt/html; #这是php-fpm服务器上的地址,并不是Nginx的本地地址哦。
                fastcgi_pass   192.168.1.250:9002;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
            }
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
        }

    8、启动php-fpm和Nginx的服务即可访问了,不过要在ServerName后面加上index.php

    参考文章:http://dragondragon.blog.51cto.com/6170889/1665580

  • 相关阅读:
    记录一个jsonb_array_elements因数据问题被坑的点
    postgresql 中的 with 用法
    Java中4个元注解
    Java8 stream filter map
    sql 函数
    sql 判断选择语句
    面试里的套路(1)
    python 路径
    postsql sqlalchemy的事务提交问题
    网站响应过慢问题
  • 原文地址:https://www.cnblogs.com/fansik/p/6635813.html
Copyright © 2020-2023  润新知