标签:
1 server { 2 listen 80; 3 server_name www.xxx.com; 4 #charset koi8-r; 5 6 #access_log logs/host.access.log main; 7 root /home/www-data/www.xxx.com; #请求的目录 ps :一般来说都会为nginx,mysql,php分配独立的用户,root权限太高 8 9 error_page 404 /404.html; 10 11 # redirect server error pages to the static page /50x.html 12 # 13 error_page 500 502 503 504 /50x.html; 14 location = /50x.html { 15 16 } 17 18 #默认请求 19 location / { 20 if (!-e $request_filename) { 21 rewrite ^/(.*)$ /index.php/$1 last; 22 break; 23 } 24 index index.php index.html; 25 } 26 #请求包含.php 27 location ~ .+\.php($|/) { 28 fastcgi_pass 127.0.0.1:9000; 29 fastcgi_index index.php; 30 include fastcgi_params; 31 set $real_script_name $fastcgi_script_name; 32 if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { 33 set $real_script_name $1; 34 set $path_info $2; 35 } 36 fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; 37 fastcgi_param SCRIPT_NAME $real_script_name; 38 fastcgi_param PATH_INFO $path_info; 39 } 40 41 # 让客户端(浏览器)缓存图片30天 42 #location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 43 #{ 44 # expires 30d; 45 #} 46 47 # 让客户端(浏览器)缓存JS和CSS文件1小时 48 #location ~ .*\.(js|css)?$ 49 #{ 50 # expires 1h; 51 #} 52 }
5).在本机上hosts将域名指向nginx服务器的ip(或者直接curl 你的域名)
nginx1.8.0配置(搭配Centos6.5+Nginx+php5.6的续章)。
标签:
原文地址:http://www.cnblogs.com/iksjweb/p/5110756.html