安装nginx

先安装zlib, pcre, openssl, 再安装nginx

 

http://www.php.cn/php-weizijiaocheng-400180.html

安装php-fpm

yum -y install gcc automake autoconf libtool make

yum -y install gcc gcc-c++ glibc

yum -y install libmcrypt-devel mhash-devel libxslt-devel mcrypt mysql \
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-develbzip2-devel 

 

git clone http://git.php.net/repository/php-src.git 

cd php-src

./configure --prefix=/opt/php7 \
--enable-fpm --with-mcrypt --enable-soap --enable-mbstring=all \
--enable-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

 

--------------------------------------------------------------------------------------------

php-fpm配置文件

*  /usr/local/php/etc/php-fpm.conf

[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
log_level = notice

[www]
listen = 127.0.0.1:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 20
pm.start_servers = 10
pm.min_spare_servers = 10
pm.max_spare_servers = 20
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = var/log/slow.log

listen 默认是socket 改为端口号形式

listen = 127.0.0.1:9000

 

* /usr/local/nginx/conf/nginx.conf

这个文件中会引入vhost, enable-php

include enable-php.conf;

 

*  /usr/local/nginx/conf/enable-php.conf 

location ~ [^/]\.php(/|$)
        {
            try_files $uri =404;
#            fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
        }

配置nginx转发php-fpm

 

* /usr/local/nginx/conf/vhost/lumen.conf   # 添加多主机

sudo touch /usr/local/nginx/conf/vhost/lumen.conf
# lumen backend
server {
listen       8000;
server_name  localhost;

#charset koi8-r;
charset utf-8;

#access_log  logs/host.access.log  main;

rewrite ^/(([^/]+/)*?[^./]+)$ $scheme://$host:$server_port/$1/ permanent;
rewrite ^/$ /index.php?path=index&$args last;

location / {
root   /opt/webdev/easywebadmin/src/backend/public;
index  index.php;
}

error_page   500 502 503 504  /50x.html;


location = /50x.html {
root   /usr/local/nginx/www/nginx-dist;
}

location ~ \.php$ {
fastcgi_pass   127.0.0.1:9000;
fastcgi_hide_header  X-Powered-By;
fastcgi_index  index.php;
proxy_set_header   Host             $http_host;
proxy_set_header   X-Real-IP        $remote_addr;
proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

fastcgi_param	SCRIPT_FILENAME	   /opt/webdev/easywebadmin/src/backend/public$fastcgi_script_name;
include        fastcgi_params;
}
location /nginx_status {
stub_status on;
access_log   off;
#allow SOME.IP.ADD.RESS;
#deny all;
}
}

相关文章:

nginx 404  https://blog.csdn.net/fareast_mzh/article/details/85101031