server { listen 80; server_name _; location / { root html/myphp; index index.php index.html; } # 添加有关php程序的解析 # 判断当请求url结尾是以php,php5的时候,就进入如下的location代码 location ~ .*\.(php|php5)?$ { root html/myphp; # 将进入到该location内的uri请求看做是cgi程序,并将请求发送到9000端口,交由php-fpm处理 fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } }