windows下安装nginx心得

配置用于fastcgi的php.ini文件,复制一份并命名为php-cli.ini

开启以下配置:

enable_dl = On
cgi.force_redirect = 0
cgi.fix_pathinfo=1
fastcgi.impersonate = 1
cgi.rfc2616_headers = 1

将nginx解压至与PHP同目录
修改conf目录下nginx.conf
添加如下server:

server {
    listen 80;
    server_name localhost;
    root D:/xampp/htdocs;

    location / {
        root D:/xampp/htdocs;
        index index.php index.html index.htm;
    }

    location ~ \.php$ {
        root D:/xampp/htdocs/;
        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.ini文件启动php
D:\xampp\php\php-cgi.exe -b 127.0.0.1:9000 -c D:\xampp\php\php-cli.ini

使用netstat -a 查看127.0.0.1:9000是否有启动

在nginx目录下
start nginx(启动nginx服务)
这里可以使用RunHiddenConsole.exe(将此软件放在nginx目录)将nginx服务作为后台运行

参考
http://avnpc.com/pages/add-nginx-to-xampp

你可能感兴趣的:(windows下安装nginx心得)