# 本文件是nginx的配置文件。
# 根據需要修改下面的域名與目錄
# 通常放置在/etc/nginx/conf.d下
server{
listen 80;
server_name api.democnsellers.cn;
root /usr/share/nginx/html/api_cnsellers/public; # 該項要修改爲你準備存放相關網頁的路徑
client_max_body_size 100M;
location / {
index index.php index.html index.htm;
#如果請求既不是一個文件,也不是一個目錄,則執行一下重寫規則
if (!-e $request_filename)
{
#地址作爲將參數rewrite到index.php上。
rewrite ^/(.*)$ /index.php?s=$1;
#若是子目錄則使用下面這句,將subdir改成目錄名稱即可。
#rewrite ^/subdir/(.*)$ /subdir/index.php?s=$1;
}
client_max_body_size 100m;
}
# location /v_2_0_0 {
# if (!-e $request_filename){
# proxy_pass http://apiv2.democnsellers.cn;
# }
# }
location ~* ^\/upload\/.+\.(html|php)$ {
return 404;
}
location ~* ^\/plugins\/.+\.(html|php)$ {
return 404;
}
location ~* ^\/themes\/.+\.(html|php)$ {
return 404;
}
#proxy the php scripts to php-fpm
location ~ \.php {
include fastcgi_params;
##pathinfo支持start
#定義變量 $path_info ,用於存放pathinfo信息
set $path_info "";
#定義變量 $real_script_name,用於存放真實地址
set $real_script_name $fastcgi_script_name;
#如果地址與引號內的正則表達式匹配
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
#將文件地址賦值給變量 $real_script_name
set $real_script_name $1;
#將文件地址後的參數賦值給變量 $path_info
set $path_info $2;
}
#配置fastcgi的一些參數
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
###pathinfo支持end
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
# fastcgi_pass 如果是 sock形式,可能是下面的配置
# fastcgi_pass unix:/tmp/php-cgi.sock
fastcgi_buffer_size 128k;
fastcgi_buffers 8 128k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_read_timeout 150;
}
}
nginx配置文件詳細介紹
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.