How to fix an unknown internal server error (500) Nginx is giving me?

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;

    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, 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 droplet here in Digital Ocean.

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

This question was answered by @EpicCDN:

Try to check /var/log/nginx/error.log if exist, if not, remove the line where you are assigning a diferent log file so he uses the standard one at /var/log/nginx/error.log

Also the socket thing is a recommendation and some people can recommend you to use tcp, but still should not be related to your error if you phpinfo.php is working.

Does this Yii requires any kind of cute urls or something similar?

try adding " fastcgi_intercept_errors on; " to the php block and check error log.

View the original comment

SELinux stopped it working for me. Guess I hadn’t rebooted the machine since I installed.