I am trying to convert trivial htaccess file to Nginx and can't make it work. It returns 404 error. Here is htaccess content:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
Here is my current nginx config:
server {
listen 80;
server_name domain.biz;
root /var/www/domain.biz;
charset utf-8;
autoindex off;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME /var/www/domain.biz$fastcgi_script_name;
}
}
How about other php files you call directly? For example an info.php with just a
phpinfo();
inside?
I ask this because your server conf seems to be using try_files just right, but I'm not sure you're serving php scripts right.
¿Is your fastcgi pool listening on that sock? ¿Are you sure it isn't listening in port 9000 for example? In any case, I prefer to define an upstream in the http section and use it later in the server section
http {
upstream phpbackend {
server unix:/var/run/php5-fpm.sock;
}
...
server {
...
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass phpbackend;
fastcgi_param SCRIPT_FILENAME /var/www/domain.biz$fastcgi_script_name;
}
}
}
Are you sure your php.ini has the cgi.fix_pathinfo set to false?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With