Nginx is giving me a 500 error that's driving me crazy. First of all I have a personalsite.conf archive inside /etc/nginx/conf.d/ where I have my server block.

This is my server block configuration:

server {
    listen       80;
    server_name  personalsite.me;

    charset UTF-8;
    access_log  /var/log/nginx/personalsite.access.log  main;
    error_log /var/log/nginx/personalsite.error.log;

    root   /usr/share/nginx/html/personalsite;
    index index.php index.html index.htm;

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html/;

    location ~ \.php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

Plus nginx user have its proper permissions asigned over /usr/share/nginx/html/personalsite/.

The thing is Nginx is giving me a 500 error when I try to browse personalsite.me, and the funny thing is that I know that because I checked the personalsite.access.log and see it, because the brower just goes blank. By unknown reasons Nginx is unable to show me its 500 error page, properly declared in the server block as you can see.

Another odd thing is that personalsite.error.log is in blank, it records nothing.

Also I have that domain declared with its IP in my /etc/hosts archive. So I really have no idea what's happening here.

Everything is running CentOS 7 over a Digital Ocean VPS.

4 Answers 4


Most error come out due to mis-configuration when Nigix setup. I will suggest to check file (/etc/php-fpm.d/www.conf).

vi /etc/php-fpm.d/www.conf

Find the line that specifies the listen parameter, and change it so it looks like the following:

listen = /var/run/php-fpm/php-fpm.sock

Next, find the lines that set the listen.owner and listen.group and uncomment them. They should look like this:

listen.owner = nobody
listen.group = nobody

Lastly, find the lines that set the user and group and change their values from "apache" to "nginx":

user = nginx
group = nginx

Then save and quit

/etc/init.d php-fpm restart

Not the best answer in the world, but a 500 error is to ambiguous, it could be your nginx config or could be related to your site content. Minimize your config and rebuild until you can reproduce the problem.

Replace the site content with a simple index.html with just some plain text in it. Leave out all the extra error directives and the location block. Once you established the basic functionality, you can feel less insane and add your other directives, testing as you go, until you will isolate any directive causing problems and can find the root cause from there.

  • 1
    Actually that helped me to understand that my Nginx is ok. The problem is with the website I'm trying to run. I replaced all the content with just a phpinfo.php file and it runs perfectly. The website I'm trying to run uses Yii Framework. I checked the official wiki and it says: "Software is nginx, php-fpm (php5-fpm). For performance, it's recommended to run php-fpm in SOCKET mode, instead of accessing via IP:PORT. That is the method shown below" I'm using Nginx exactly like that. So I have no idea why it gives me a 500 error and wont write on the error.log.
    – Alain
    Mar 20, 2015 at 13:51

When PHP display_errors are disabled, PHP errors can return Nginx 500 error.

You should take a look to your php-fpm logs, i'm sure you'll find the error there. With CentOS 7 :

tail -f /var/log/php-fpm/www-error.log

You can also show PHP errors. In /etc/php.ini, change :

display_errors = Off

to :

display_errors = On

With php-fpm you need also edit www.conf in /path/php/version/fpm//pool.d/

catch_workers_output = yes

Without this modification php-fpm never write in your logs

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .