Nginx 配置 PHP

2016-6-17 chenhui Nginx

Nginx 通过 fastCGI 的方式调用 PHP,所以我们要先安装 PHP-fpm,安装方式百度上都有就不写了。

安装完后,直接在 server {} 内填入如下即可



server {
        listen       80;
        server_name  localhost;
        root /usr/wwwroot;
        index        index.php;
        location / {
           index  index.php; ##可以有多个,空格隔开
        }
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
}


发表评论:

Copyright ©2015-2016 freehui All rights reserved