【nginx+PHP】nignx下php的配置

来源:互联网 发布:怎么注册淘宝达人 编辑:程序博客网 时间:2024/05/29 23:23

讲讲如何在Nginx下配置PHP环境,需要工具:
Nginx + php
PHP执行需要WEB容器,可以选用Apache也可以选用nginx。

首先下载PHP,可以源码安装也可以直接安装。


【修改PHP.ini文件】
PHP.ini文件修改说明

在Nginx下配置需要再删除【doc_root=】这一行代码,注释也可以。
接下来配置nginx.conf文件:

server {        listen       7777;        server_name  localhost;        location ~ \.php$ {            root           E:/mycode/php/;            fastcgi_pass   127.0.0.1:9000;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;            include        fastcgi_params;        }        error_page   500 502 503 504  /50x.html;        location = /50x.html {            root   html;        }    }

接着启动PHP,监听9000端口

 .\php-cgi -b 127.0.0.1:9000