Windows下安装Nginx+PHP

回覆文章
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Windows下安装Nginx+PHP

文章 yehlu »

http://www.hqqblog.com/vps-windows-nginx-php-mysql/

php.ini

代碼: 選擇全部

; 指定doc_root,即网站的根目录:
doc_root = "C:\Z"
扩展存放目录 extension_dir,Windows下一般是ext目录:
extension_dir = "ext"
; 修改时区:
date.timezone = Asia/Taipei
;For Nginx
enable_dl = On
cgi.force_redirect = 0
cgi.fix_pathinfo=1
fastcgi.impersonate = 1
cgi.rfc2616_headers = 1
nginx.conf

代碼: 選擇全部

# 启用错误日志
error_log  logs/error.log;

# 启用GZIP压缩(放在http{}里面,sever{}之前)
gzip on;
gzip_min_length 1000;
gzip_buffers 4 8k; 
gzip_http_version 1.1; 
gzip_types text/plain application/x-javascript text/css application/xml;

# 修改编码,为了更好地兼容简化中文版Windows,若您用的是英文版Windows则可以修改为uft-8
charset utf-8;

location / {
# 把root后面的路径改为网站的根目录
root "C:\Z";
# 添加index.php
index index.php index.html index.htm;
autoindex on;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
# root后面跟什么不用再解释了吧=。=
root "C:\Z";
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# 把"scripts"改为$document_root,指代的就是root 上面的目录
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
start.bat

代碼: 選擇全部

echo Starting Nginx...
cd C:\P\nginx\ && C:\P\RunHiddenConsole.exe "C:\P\nginx\nginx.exe"
echo Starting PHP FastCGI...
C:\P\RunHiddenConsole.exe c:\P\php\php-cgi.exe -b 127.0.0.1:9000  -c c:\P\php\php.ini
cd C:\P\
stop.bat

代碼: 選擇全部

echo Stopping nginx...
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > nul
回覆文章

回到「PHP」