what's the simplest way to serve php files through an alias?

Edho P Arief edhoprima at gmail.com
Sun Oct 3 08:40:29 MSD 2010


On Sun, Oct 3, 2010 at 11:31 AM, Ilan Berkner <iberkner at gmail.com> wrote:
> Thanks for the advice.  When I do it this way, I get an error (nginx error
> log):
> 2010/10/03 00:27:33 [error] 20239#0: *6447
> "/usr/local/nagios/share/nagios/index.php" is not found (2: No such file or
> directory)
> so you can see that nginx is adding /nagios/ to the end of the root
> directory and so the file is not found (generating a 404 on the browser).
> What would be the correct way to address this issue?
>
>

>         location /nagios/
>         {
>                 root /usr/local/nagios/share;
>                 index index.php;
>         }

use alias.

location ~ ^/nagios/(.*\.php)$ {
  alias /usr/local/nagios/share/$1;
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $request_filename;
  include fastcgi_params;
}
location = /nagios {
  rewrite ^ /nagios/ permanent;
}
location /nagios/ {
  index index.php;
  alias /usr/local/nagios/share/;
}

-- 
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org



More information about the nginx mailing list