I have domain configured as followed:
server {
listen 80;
root /var/www/domains/somedomain/root;
location = /service/alias/ {
alias /var/www/service/alias/;
index index.php;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
I want to execute the index.php
file in /var/www/service/alias/
when someone requests http://example.com/service/alias. I've tried many variations (putting the FastCGI parameters in the location and supply the full path for the index.php
script), but i keep getting "No input file specified" errors from php-fastcgi.
Anyone an idea of what i'm doing wrong? Or at least how can Ii log the full errors of php-fastcgi?
index
is better in a server scope because then all other locations will inheret that value, especially if they are multiple index that are equal, and I like my php block to be as minimal as possible because most other options are already included in fastcgi_params
, and I also believe that fastcgi_pass
should be passed to an http://
not IP directly, so try this version and tell me if it works for you.
server {
listen 80;
# added a server name, unless it's a catch all virtual host
# then you better use `default_server` with `listen`
server_name example.com;
root /var/www/domains/somedomain/root;
# index moved here
index index.php;
location = /service/alias/ {
# why `=` ? I would remove it unless there's a purpose
# index removed from here
alias /var/www/service/alias/;
}
location ~* \.php$ {
#removed all other options
include fastcgi_params;
# added `http` before `127.0.0.1`
fastcgi_pass http://127.0.0.1:9000;
}
}