So yay, Nginx has been a new playground for me here. It's awesome thus far and I love the process management! I've still got a bunch of exploring to do and I'm super busy, so excuse the brevity!
FastCGI Issues With Aliases
I've scoured the web for help on this one and it seems like a common issue that people have had. Check out the comment section on this post for a good starting point on this issue. But the usual trial and error was what ultimately got everything working for me.
Here's what I got working for me below:
location /dir/ {
alias /usr/local/www/foo/;
index index.php;
}
location ~ /dir/.*\.php$ {
if ($fastcgi_script_name ~ /dir(/.*\.php)$) {
set $valid_fastcgi_script_name $1;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/www/foo$valid_fastcgi_script_name;
include fastcgi_params;
}
The problem I was running into was here:
location ~ /dir/.*\.php$ {
if ($fastcgi_script_name ~ /dir(/.*\.php)$) {
set $valid_fastcgi_script_name $1;
}
I assumed $fastcgi_script_name
was going to be from /foo
but it was already being passed the alias (/dir
).
I suppose I'm just writing this to remind me in the future, but in case this helps anyone else, hope it makes sense!
Cheers!