laravel admin 配置二级虚拟目录
server {
listen 80;
server_name example.com;
#access_log /path/access.log;
#error_log /path/error.log debug;
location /sub {
#注意 root 和 alias 的区别
alias /path/of/phpapp/;
index index.php;
try_files $uri $uri/ $uri/index.php /sub/index.php;
location ~ [^/]\.php(/|$) {
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
# 执行文件路径 /path/of/php/index.php
fastcgi_param SCRIPT_FILENAME $request_filename;
}
}
# server static file in another directory
location ^~ /static/files {
alias /static/files/path;
}
}
参考资料
https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/ http://nginx.org/en/docs/http/ngx_http_core_module.html#alias http://nginx.org/en/docs/http/ngx_http_core_module.html https://nginx.org/en/docs/beginners_guide.html#fastcgi