Welcome! Log In Create A New Profile

Advanced

Questions about Internal named location

July 30, 2010 02:31PM
I have a problem I can't find an answer too and I'm wondering if I'm doing the named internal location all wrong. Here is an example of my config

location / {
try_files $uri $uri/ @www;
}

location @www {
include fastcgi_params;

fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass myphp;
}

When I go to /index.php I get the index.php recognized as a binary file and the browser just wants to download the file. The file that is downloaded is correct html so I know that the file hit myphp before it was sent to my browser.

If I add this location:

location ~ \.php$ {
fastcgi_pass myphp;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

index.php is displayed in the browser correctly so my question is why does the @www location not correctly handle the php file?

This all started when I tried to setup one nginx server that has multiple php sites under one url that needs a alias for the other sites. Something like this:

root /var/www/somesite;

location / {
index.html index.php;
}
location /wordpress {
alias /var/www/wordpress;
try_files $uri $uri/ @wordpress;
}
....

Can anyone shed some light on how the try_files/named location works? I'm using Nginx 0.8.36 btw
Subject Author Posted

Questions about Internal named location

heimdull July 30, 2010 02:31PM

Re: Questions about Internal named location

Rob Schultz July 30, 2010 03:46PM

Re: Questions about Internal named location

Igor Sysoev July 30, 2010 03:50PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 255
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready