displaying standard 404 page, if php file is not found

Igor Sysoev is at rambler-co.ru
Wed Jul 29 19:00:04 MSD 2009


On Wed, Jul 29, 2009 at 04:53:43PM +0200, Samuel Vogel wrote:

> Am 29.07.09 16:12, schrieb Edho P Arief:
> >On Wed, Jul 29, 2009 at 9:03 PM, Samuel Vogel<samydelux at gmail.com>  wrote:
> >   
> >>Hey,
> >>
> >>I know this question has come up a couple of times, but the solutions 
> >>posted
> >>here do not seem to work for me!
> >>Here is the important part of my configuration:
> >>
> >>    location ~ \.php$ {
> >>        try_files  $uri  @404;
> >>
> >>        fastcgi_pass   unix:/var/run/php-fpm/domain.sock;
> >>        fastcgi_index  index.php;
> >>        fastcgi_param  SCRIPT_FILENAME  www/$fastcgi_script_name;
> >>        include fastcgi_params;
> >>    }
> >>
> >>    location @404 {
> >>        return 404;
> >>    }
> >>
> >>This returns a 404 error for every PHP file, even existing ones!
> >>
> >>     
> >where did you set the root directive? in another location block or in
> >server block?
> >
> >also I don't remember ever seeing relative path for script_filename
> It's not relative, php ist just chrootet to /var/www/domain/.
> 
> Here is my complete configuration:
> server {
>     listen   80;
>     server_name  domain.de;
> 
>     access_log  /var/log/nginx/domain.access.log;
> 
>     location / {
>         root   /var/www/domain/www;
>         index  index.html index.php;
>     }
> 
>     location ~ \.php$ {
>         try_files  $uri  @404;

+         root   /www;

>         fastcgi_pass   unix:/var/run/php-fpm/domain.sock;
>         fastcgi_index  index.php;
>         fastcgi_param  SCRIPT_FILENAME  /www/$fastcgi_script_name;
>         include fastcgi_params;
>     }
> 
>     location @404 {
>         return 404;
>     }
> 
>     location ~ /\.ht {
>         deny  all;
>     }
> }


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list