Nginx – Blank page (500 error) with nginx and php-fpm

500-errornginxphp-fpm

I am hosting more than one domain on the same server. I have the following configuration for nginx:

server {
    listen 80;

    root /var/www/mydomain.com;
    index index.php index.html index.htm;

    server_name mydomain.com;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Which works with all the domains I have on the server. However, today, I added a new domain which I transferred its content from another server (I transferred from shared hosting into a VPS). And after adjusting the DNS, moving the files and migrating the database and finishing everything up, the new domain doesn't work. It just returns 500 error code. No log messages were shown in nginx's log files.

Best Answer

What drove me mad is that I am using the same configuration with all my websites and domains on the same server. It works with all of them except this one, although they are completely matched.

There are other cases on ServerFault where the problem may be from fastcgi parameters or php-fpm. But in my cause, it was awkwardly ridiculous.

It was because of the hidden .htaccess file which I transferred from my holder hosting. It contained rules which doesn't work with the new VPS. I removed the file, and Voala! Works like a charm.

(I can't deny that I have been insulting myself for hours about how I am the worst sysadmin in the world).