简单将Nginx的站点配置文件贴出来,方便日后查看。
server {
listen 80; ## listen for ipv4
server_name domain.com;
access_log /var/log/nginx/domain.com.access.log;
location / {
root /var/www/domain.com;
index index.php index.html index.htm ;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ \.php$ {
fastcgi_pass unix:///run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME /var/www/domain.com$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
}
关键部位注意location /
中的if
部分以及location ~ \.php$
部分的if
和fastcgi_param
部分。