feat: implement dynamic Nginx project configuration and IPC service management for PHP environments
This commit is contained in:
@@ -1,25 +1,31 @@
|
||||
location ^~ /{{HOST}}/ {
|
||||
alias "{{PATH}}/";
|
||||
alias "{{PATH}}";
|
||||
index index.php index.html;
|
||||
autoindex on;
|
||||
|
||||
# Try the literal URI, then directory (checks for index), then fallback to root index.php
|
||||
try_files $uri $uri/ /{{HOST}}/index.php?$query_string;
|
||||
# Use a named location for reliable alias fallback
|
||||
try_files $uri $uri/ @{{HOST}};
|
||||
|
||||
# PHP handling nested INSIDE the alias location to maintain context
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass 127.0.0.1:{{PHP_PORT}};
|
||||
fastcgi_index index.php;
|
||||
|
||||
# Split path info to handle subdirectories correctly
|
||||
fastcgi_split_path_info ^/{{HOST}}(.+\.php)(.*)$;
|
||||
|
||||
include "{{CONF_DIR}}/fastcgi_params";
|
||||
|
||||
# Bulletproof SCRIPT_FILENAME: combine base path with relative script name from split_path_info
|
||||
# On Windows + Alias, $request_filename can be flaky during try_files redirects
|
||||
fastcgi_param SCRIPT_FILENAME "{{PATH}}$fastcgi_script_name";
|
||||
fastcgi_param DOCUMENT_ROOT "{{PATH}}";
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
# Normal files matched correctly by URI don't suffer the try_files bug
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
}
|
||||
}
|
||||
|
||||
# The named location handles requests that don't match physical files
|
||||
location @{{HOST}} {
|
||||
# Directly execute PHP without URI mutation to preserve framework routing paths
|
||||
fastcgi_pass 127.0.0.1:{{PHP_PORT}};
|
||||
include "{{CONF_DIR}}/fastcgi_params";
|
||||
|
||||
# Hardcode the essential execution parameters
|
||||
fastcgi_param SCRIPT_FILENAME "{{PATH}}index.php";
|
||||
fastcgi_param SCRIPT_NAME "/{{HOST}}/index.php";
|
||||
fastcgi_param DOCUMENT_ROOT "{{PATH}}";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user