Nginx + PHP-FPM设置虚拟主机 + 开启PATHINFO模式

 

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

 

user  nginx nginx;
worker_processes  2;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;
    client_max_body_size 5m;

    #设置404
    fastcgi_intercept_errors on;

    include vhost/*.conf;
}

 

/usr/local/nginx/conf/vhost/www.example.com.conf

 

server {
    listen       80;
    server_name  www.example.com example.com;

    charset utf-8;
    access_log  /data/log/nginx/example.access.log;

    root    /data/example/www;

    if ($host != 'www.example.com') {
        rewrite ^/(.*)$ http://www.example.com/$1 permanent;
    }

    location /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location / {
        index   index.php index.html index.htm;
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /index.php/$1 last;
        }
    }

    location ~ \.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        fastcgi_pass   unix:/dev/shm/php-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  PATH_INFO        $fastcgi_path_info;
        include        fastcgi_params;
    }

    location ~ /\.ht {
        deny  all;
    }
}

 

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

 

pid = run/php-fpm.pid

user = nginx
group = nginx

;listen = 127.0.0.1:9000
listen = /dev/shm/php-fpm.sock

listen.owner = nginx
listen.group = nginx
listen.mode = 0660

 

/usr/local/php/etc/php-fpm.d/www.conf

 

现在nginx多了一个php-fpm.d/www.conf,把之前在php-fpm.conf里面的一些配置分到了php-fpm.d下面的多个conf里面

 

user = nginx
group = nginx

;listen = 127.0.0.1:9000
listen = /dev/shm/php-fpm.sock

listen.owner = nginx
listen.group = nginx
listen.mode = 0660