您的位置:首页 > 运维架构 > Nginx

windows下PHP和nginx的简单配置

2015-05-05 16:42 337 查看
用markdown写出来的博客真是很清晰、漂亮

1. 下载PHPnginx

2. php配置

修改php.ini-development文件,将文件名修改为php.ini

去掉以下关键字前面的分号

关键字说明
error_reporting = E_ALL。设置错误报告的级别
display_errors = On。是否将错误信息显示到控制台
default_charset = “UTF-8”。默认字符集UTF-8
extension_dir = “./ext”。可加载库的文件夹路径
如:extension=php_curl.dll。选择要加载的动态库
cgi.force_redirect = 1。使用PHP作为CGI
cgi.rfc2616_headers = 1。PHP会发送HTML1.1标准协议头部
cgi.fix_pathinfo = 1。PHP会自动检测PATH_INFO

3. nginx配置

nginx HttpFastcgiModule

[code]#虚拟主机的配置
    server {
        listen       80;
        #域名可以有多个,用空格隔开
        server_name  localhost 127.0.0.1;

        #定义服务器的默认网站根目录位置 
        root D:\myphp;

        #定义首页索引文件的名称   
        index  index.html index.htm index.php;
        #默认请求,如请求静态文件
        location / {

        }
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #对请求PHP动态页面请求的处理
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;                       
            #调用fastcgi.conf配置文件来传递服务器变量,这样CGI中可以获取到这些变量的值。         
            include  fastcgi.conf;
        }
}


4. 测试运行系统

在D:myphp中新建index.php文件:

[code]<?php phpinfo(); ?>


开启php-cgi和nginx.exe,保存为startPhpAndNginx.bat

[code]@echo off
echo Starting PHP FastCGI
start c:/php/php-cgi.exe -b 127.0.0.1:9000 -c c:/php/php.ini
echo Starting nginx
start  C:/nginx/nginx.exe -p C:/nginx
echo Success
PAUSE
exit


停止php-cgi和nginx.exe,保存为stopPhpAndNginx.bat

[code]@echo off
echo Stopping nginx...
C:/nginx/nginx.exe -p C:/nginx -s stop
echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > nul
PAUSE
exit


5. 访问127.0.0.1

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: