server {
listen 80;
server_name blog.sweetsunnyflower.com;
index index.html index.htm index.php;
charset utf-8;
# 项目1
location ^~ /project1/ {
alias /var/www/project1/public/;
try_files $uri $uri/ @project1;
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
location @project1 {
rewrite /project1/(.*)$ /project1/index.php?/$1 last;
}
# 项目2
location ^~ /project2/ {
alias /var/www/project2/public/;
try_files $uri $uri/ @project2;
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
location @project2 {
rewrite /project2/(.*)$ /project2/index.php?/$1 last;
}
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log error;
sendfile off;
}