Trying to setup 2 applications with same domain, but different paths. I am running php-fpm with nginx and would need every uri starting with "/sub" to be directed to index.php file of /var/www/sub and all others to be directed to /var/www/main.
Latest test can be found below which resolves my locations (as I see in logs), but in error log I get:
open() "/var/www/sub/test/test" failed (2: No such file or directory)
server {
listen 80;
server_name example.com;
access_log /var/log/nginx/default_access.log;
error_log /var/log/nginx/default_error.log debug;
location / {
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log debug;
alias /var/main/public;
index index.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
}
location ^~ /sub {
access_log /var/log/nginx/sub_access.log;
error_log /var/log/nginx/sub_error.log debug;
alias /var/sub/public;
index index.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
}
}
What might be wrong with this configuration or where should I look next?
EDIT: changed alias paths from /var/main to /var/main/public and /var/sub to /var/sub/public