I am trying to configure Nginx to host multiple PHP based apps in two different directories in the same domain. The outcome I'm trying to get to is:
http://webserver.local/ > app served from /path/to/website
http://webserver.local/app > app served from /path/to/php-app
Here is the configuration I have.
- Everything works (being PHP and non-PHP resources) when I hit http://webserver.local/.
- However, PHP scripts are not working when I go to http://webserver.local/app/index.php. I get
File Not Found
(however, file is there at/path/to/php-app/index.php
). - I created a file
/path/to/php-app/test.txt
(something not PHP), and when I go to http://webserver.local/app/test.txt, I get the text file as expected.
Can someone please shed some light as to where I am going wrong? Thanks :)
server {
listen 80;
server_name webserver.local;
location / {
root /path/to/website;
index index.php;
location ~ \.php$ {
root /path/to/website;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
location ^~ /app {
alias /path/to/php-app;
index index.php;
location ~ \.php$ {
root /path/to/php-app;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}