NGINX and Slim PHP framework

Edho Arief me at myconan.net
Sat Oct 22 10:41:44 UTC 2016


Hi,

On Sat, Oct 22, 2016, at 19:37, Ben wrote:
> Hi,
> 
> nginx/1.10.0 & PHP 7.0.8
> 
> I'm struggling to get NGINX to work with the Slim PHP framework for
> paths.
> 
> The base index.php works fine (e.g. http://example.com works), however 
> if I try a framework path (e.g. http://example.com/hello/test), NGINX 
> sends me what Firefox seems to call a "DMS file" (if I download and open 
> it, it displays the source code from the PHP file).
> 
> My NGINX config looks as follows:
> 
> server {
> 	listen 80 default_server;
> 	listen [::]:80 default_server;
> 	root /var/www/html/bobs/public;
> 	index index.php;
> 	server_name _;
> 	location / {
> 		try_files $uri $uri/ /index.php$is_args$args =404;

try_files immediately returns the file without doing another location
lookup so here it'll just return the index.php as is. index.php should
be the last one. It doesn't make sense to have =404 anyway since
index.php part will always succeed.



More information about the nginx mailing list