windows下nginx和php环境的配置
至于php的配置,与之前博文中使用apache服务器时一样。
对于nginx的配置,来看看如何修改配置文件:
1 #user nobody; 2 worker_processes 1; 3 4 #error_log logs/error.log; 5 #error_log logs/error.log notice; 6 #error_log logs/error.log info; 7 8 #pid logs/nginx.pid; 9 10 11 events { 12 worker_connections 1024; 13 } 14 15 16 http { 17 include mime.types; 18 default_type application/octet-stream; 19 20 #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 21 # '$status $body_bytes_sent "$http_referer" ' 22 # '"$http_user_agent" "$http_x_forwarded_for"'; 23 24 #access_log logs/access.log main; 25 26 sendfile on; 27 #tcp_nopush on; 28 29 #keepalive_timeout 0; 30 keepalive_timeout 65; 31 32 #gzip on; 33 34 server { 35 listen 80; 36 server_name localhost; 37 38 #charset koi8-r; 39 40 #access_log logs/host.access.log main; 41 42 root E:/www; 43 44 location / { 45 #root html; 46 index index.php index.html index.htm; 47 } 48 49 #error_page 404 /404.html; 50 51 # redirect server error pages to the static page /50x.html 52 # 53 error_page 500 502 503 504 /50x.html; 54 location = /50x.html { 55 root html; 56 } 57 58 # proxy the PHP scripts to Apache listening on 127.0.0.1:80 59 # 60 #location ~ \.php$ { 61 # proxy_pass http://127.0.0.1; 62 #} 63 64 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 65 # 66 location ~ \.php { 67 # root html; 68 fastcgi_pass 127.0.0.1:9000; 69 # fastcgi_index index.php; 70 set $real_script_name $fastcgi_script_name; 71 set $path_info ""; 72 if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") 73 { 74 set $real_script_name $1; 75 set $path_info $2; 76 } 77 fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; 78 include fastcgi_params; 79 fastcgi_param SCRIPT_NAME $real_script_name; 80 fastcgi_param PATH_INFO $path_info; 81 } 82 83 # deny access to .htaccess files, if Apache's document root 84 # concurs with nginx's one 85 # 86 #location ~ /\.ht { 87 # deny all; 88 #} 89 } 90 91 92 # another virtual host using mix of IP-, name-, and port-based configuration 93 # 94 #server { 95 # listen 8000; 96 # listen somename:8080; 97 # server_name somename alias another.alias; 98 99 # location / { 100 # root html; 101 # index index.html index.htm; 102 # } 103 #} 104 105 106 # HTTPS server 107 # 108 #server { 109 # listen 443 ssl; 110 # server_name localhost; 111 112 # ssl_certificate cert.pem; 113 # ssl_certificate_key cert.key; 114 115 # ssl_session_cache shared:SSL:1m; 116 # ssl_session_timeout 5m; 117 118 # ssl_ciphers HIGH:!aNULL:!MD5; 119 # ssl_prefer_server_ciphers on; 120 121 # location / { 122 # root html; 123 # index index.html index.htm; 124 # } 125 #} 126 127 }
现在nginx在遇到请求php文件会交给 php-cgi 去处理,第66行到第89行是与php相关的配置。
啦啦啦!!!