nginx php 配置模板

server {
    listen 80;
    server_name    www.xxx.com;
    #access_log     logs/www.xxx.com.access.log main;
    location / {
        index index.html index.htm index.php;
        root  /home/wwwroot/www.xxx.com;
    }
    location ~ .php$ {
            root           /home/wwwroot/www.xxx.com;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /home/wwwroot/www.xxx.com$fastcgi_script_name;
            include        fastcgi_params;
        }
}

其中php方面的 root是你的网站目录

fastcig_pass 是与php-fpm进行交互的端口,此处修改也需要修改php-fpm.conf中的相应监听端口

原文地址:https://www.cnblogs.com/itafter/p/4764848.html