Home > Article > Backend Development > nginx configuration
# 扫描指定目录的文件
# include vhost/*.conf;
log_format domaintradefork '$remote_addr - $remote_user [$time_local] $request ' '$status $body_bytes_sent $http_referer ' '$http_user_agent $http_x_forwarded_for';
server
{
listen 80;
server_name domaintradefork.dev.bizcn.com mingfork.dev.bizcn.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/domaintradefork/htdocs;
if (!-e $request_filename) {
rewrite ^/index.php/(.*)$ /index.php?s=$1 last;
rewrite ^/(.*)$ /index.php?s=$1 last;
}
include none.conf;
location ~ .*.(php|php5)?$
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-domaintradefork.sock;
fastcgi_index index.php;
# ----------------------------------
# include fastcgi_pathinfo.conf;
# ----------------------------------
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param SCRIPT_NAME $fastcgi_script_name; #这两行是需要注释掉的,请注意
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
#定义变量 $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;
}St#Some parameters of configuration of FastCGI
FastCGI_PARAM Script_filename $ Document_root $ Real_Script_name; aSTCGI_PARAM PATH_INFO $ PATH_INFO;}}
local ~.*. {I Expires 30d;
}
local ~.*. (Js | css)? $
{
Expires 12h;
}
access_log /home/domaintradeFiles/access.log domainTradeference ;
}
The above introduces the nginx configuration, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.