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

Ilan Berkner iberkner at gmail.com
Sun Oct 3 04:23:27 MSD 2010


Thanks,

I tried it using "root" in the location, still no luck.

Here's my config (the parts that matter), the location /nagios/ is what's
not working.  What am I doing wrong? Thanks

http
{
    root /var/www/html;
    server
    {
        listen  10.0.1.163;
        server_name  dev.testsite.com;
        location /nagios/
        {
                root /usr/local/nagios/share;
                index index.php;
        }
        location /
        {
                index  index.php;
                error_page 404 = @joomla;
                log_not_found off;
        }
        location @joomla
        {
                rewrite ^(.*)$ /index.php?q=$1 last;
        }

        location ~ \.php$
        {
                include fcgi;
                fastcgi_pass 127.0.0.1:9000;
        }

    }
}



On Sat, Oct 2, 2010 at 7:23 PM, António P. P. Almeida <appa at perusio.net>wrote:

> On 3 Out 2010 00h05 WEST, iberkner at gmail.com wrote:
>
> > we have a very simple configuration.
> >
> > server block with location block
> >
> > php is served through fastcgi and works fine
> >
> > would like to add something like this:
> >
> > location /nameofalias/
> > {
> > alias /usr/local/nameofalias;
> > }
>
> This is now how alias is supposed to be used. In fact you're using
> alias like a root directive. Using alias is for when you want to use a
> certain base directory and don't want the URI to reflect that.
>
> location /foo {
>  alias /var/www/nginx-default/barz;
> }
>
> Request for /foo/xpto.png is translated to
>
>   /var/www/nginx-default/barz/xpto.png
>
> > but it does not seem to work, static files load fine.
>
> > the php location block is like this and works fine for the main
> > location block of "location /"
> >
> > location ~ .php$
> > {
> > include fcgi;
> > fastcgi_pass 127.0.0.1:9000;
> > }
>
> You should have a fastcgi_pass directive where you want the PHP files
> to be handled.
>
> Also you need to escape the "." as in
>
> location ~ \.php$ {
>  (...)
> }
>
> --- appa
>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20101002/e4995025/attachment.html>


More information about the nginx mailing list