displaying standard 404 page, if php file is not found
Samuel Vogel
samydelux at gmail.com
Wed Jul 29 18:53:43 MSD 2009
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;
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;
}
}
More information about the nginx
mailing list