让nginx支持PHP

MAC为例

1、安装nginx

brew install nginx

2、查找nginx配置文件在什么地方

find /|grep nginx.conf

3、修改配置文件nginx.conf

cd /usr/local/etc/nginx
vi nginx.conf

location / {
            #root   html;
            root   /Users/zhoutingze/project/maturi/maturi/docroot/web;
            index  index.html index.htm index.php;
            rewrite (.*) /index.php;
        }

location ~ \.php$ {
            root           /Users/zhoutingze/project/maturi/maturi/docroot/web;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

4、cgi方式启动php

cd /Applications/XAMPP/bin
./php-cgi -b 127.0.0.1:9000 -c /Applications/XAMPP/etc/php.ini

5、启动nginx

sudo nginx

6、关闭nginx

sudo nginx -s stop

  

posted @ 2015-08-12 10:41  Adtuu  阅读(319)  评论(0编辑  收藏  举报