/ 中存储网

Windows系统安装配置Nginx+PHP5.3服务器环境

2014-01-10 12:52:01 来源:IT技术网
1.下载nginx-0750-win32-setup.exe 及php5.3.4(一定要是php-5.3.4-Win32-VC6-x86,而不能是php-5.3.4-nts-Win32-VC6-x86,该版本没有php5ts.dll)

2.安装nginx(默认安装到C:nginx),安装php 到C:php ,接下来就是nginx 配置:

#user  nobody;

worker_processes  1;

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {

worker_connections  1024;

}

http {

include       mime.types;

default_type  application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

#                  '"$status" $body_bytes_sent "$http_referer" '

#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;

tcp_nopush     on;

#keepalive_timeout  0;

keepalive_timeout  65;

#gzip  on;

server {

listen       80;

server_name  localhost;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {

root   html;

index  index.html index.htm index.php;

}

#error_page  404              /404.html;

# redirect server error pages to the static page /50x.html

#

error_page   500 502 503 504  /50x.html;

location = /50x.html {

root   html;

}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80

#

#location ~ .php$ {

#    proxy_pass   http://127.0.0.1;

#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

location ~ .php$ {

#root           html;

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

fastcgi_param  SCRIPT_FILENAME  /nginx/html$fastcgi_script_name;

include        fastcgi_params;

}

# deny access to .htaccess files, if Apache's document root

# concurs with nginx's one

#

#location ~ /.ht {

#    deny  all;

#}

}

}

3.拷贝PHP目录下的php.ini-production至C:WINDOWS下并改名php.ini

编辑php.ini文件(修改doc_root = "C:nginxhtml" 798行 extension_dir = "C:phpext" 809行 开启extension=php_gd2.dll extension=php_mysql.dll等) date.timezone = Asia/Shanghai(保证获取当前时间不会有8小时之差)拷贝PHP目录下的php5ts.dll和libmysql.dll(开启MYSQL)至C:WINDOWSsystem32下(干脆就将PHP目录下的DLL文件都拷贝至C:WINDOWSsystem32下)

4.启动nginx 服务器,再启动php 的cgi sever 。关于php cgi server 可以使用以下命令:

php-cgi.exe -b 127.0.0.1:9000 -q

C:php>php-cgi.exe -b 127.0.0.1:9000 -q(在CMD命令符下运行,直接打开不能启动)

5.写一个简单PHPINFO 来验证PHP 是否工作正常。