Nginx + PHP-FPM + Error 500 without any log or clue

Discussion in 'Installation/Configuration' started by minttux, Jan 23, 2024.

  1. minttux

    minttux Member

    Hi I moved a WordPress website to my server
    It's config:
    [​IMG]
    Also its:
    [​IMG]
    all display errors is active everywhere
    it's nginx host config:
    Code:
    server {
            listen 45.156.186.103:80;
            listen 45.156.186.103:443 ssl http2;
    
        ssl_protocols TLSv1.3 TLSv1.2;
            ssl_certificate /var/www/clients/client1/web3/ssl/mysite.com-le.crt;
            ssl_certificate_key /var/www/clients/client1/web3/ssl/mysite.com-le.key;
    
            server_name mysite.com www.mysite.com;
    
            root   /var/www/mysite.com/web/;
            disable_symlinks if_not_owner from=$document_root;
    
    
            index index.html index.htm index.php index.cgi index.pl index.xhtml standard_index.html;
    
    
            error_page 400 /error/400.html;
            error_page 401 /error/401.html;
            error_page 403 /error/403.html;
            error_page 404 /error/404.html;
            error_page 405 /error/405.html;
            error_page 500 /error/500.html;
            error_page 502 /error/502.html;
            error_page 503 /error/503.html;
            recursive_error_pages on;
            location = /error/400.html {
    
                internal;
                auth_basic off;
            }
            location = /error/401.html {
    
                internal;
                auth_basic off;
            }
            location = /error/403.html {
    
                internal;
                auth_basic off;
            }
            location = /error/404.html {
    
                internal;
                auth_basic off;
            }
            location = /error/405.html {
    
                internal;
                auth_basic off;
            }
            location = /error/500.html {
    
                internal;
                auth_basic off;
            }
            location = /error/502.html {
    
                internal;
                auth_basic off;
            }
            location = /error/503.html {
    
                internal;
                auth_basic off;
            }
    
            error_log /var/log/ispconfig/httpd/mysite.com/error.log;
            access_log /var/log/ispconfig/httpd/mysite.com/access.log combined;
    
            location ~ /\. {
                deny all;
            }
    
            location ^~ /.well-known/acme-challenge/ {
                access_log off;
                log_not_found off;
                auth_basic off;
                root /usr/local/ispconfig/interface/acme/;
                autoindex off;
                index index.html;
                try_files $uri $uri/ =404;
            }
    
            location = /favicon.ico {
                log_not_found off;
                access_log off;
                expires max;
                add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            }
    
            location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
            }
    
            location /stats/ {
    
                index index.html index.php;
                auth_basic "Members Only";
                auth_basic_user_file /var/www/clients/client1/web3/web//stats/.htpasswd_stats;
                add_header Content-Security-Policy "default-src * 'self' 'unsafe-inline' 'unsafe-eval' data:;";
            }
    
            location ^~ /awstats-icon {
                alias /usr/share/awstats/icon;
            }
    
            location ~ \.php$ {
                try_files /2a19ffe1b31e630e6abc24bb4385b395.htm @php;
            }
    
            location @php {
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass unix:/var/lib/php8.1-fpm/web3.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
            }
    }
    The permissions:
    [​IMG]
    And only get this error:
    [​IMG]
    Nothing anywhere logs any clue and I don't understand why I can solve the problem when I don't know what the problem
    [​IMG]
    Code:
    # lsb_release -a
    No LSB modules are available.
    Distributor ID:    Ubuntu
    Description:    Ubuntu 22.04.3 LTS
    Release:    22.04
    Codename:    jammy
    
    ISPConfig Version: 3.2.11p1
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    If there is no log, then the reason might be that your request ends up in a different vhost. Also info.php is owned by root, this might cause a error as well when you get it when trying to access info.php, chown it to the website user and group.
     
    ahrasis likes this.
  3. minttux

    minttux Member

    PHP info is accessible (without changing any permissions)
    [​IMG]
    Also on this server, I have only this website:
    [​IMG]
    I just freshly installed Ispconfig yesterday. move this website to this server and it just returns Error500
    so there is no different vhost or maybe I could not understand your mind but now what should I do? How fix the problem? how can I see log? i think the problem is related to PHP-FPM and I chose php7.4 but I config file it's connected to 8.1

    Code:
            location @php {
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass unix:/var/lib/php8.1-fpm/web3.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
            }
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    This is not the case. You can not see the PHP version in the vhost file at all, and the number 8.1 does not refer to a PHP version, its just a folder name of the central PHP socket folder used by all PHP versions. You can see from the info.php file that the site uses PHP 7.4.
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Do you use any custom nginx directives in that website?
     
  6. minttux

    minttux Member

    I posted all configs in nginx vhost before only Directive I use is PHP to show errors:
    [​IMG]
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    You seem to be using WordPress, for WordPress you should add these Directives on a Nginx system as nginx, unlike apache, does not support rules in .htaccess format. Put this into the nginx directives field:

    Code:
    location / {
                    try_files $uri $uri/ /index.php?$args;
           }
    
           # Add trailing slash to */wp-admin requests.
           rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    
           location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
                    expires max;
                    log_not_found off;
           }
     
  8. minttux

    minttux Member

    this site in before server (Cpanel) takes more memory and returns error 503 so I moved it to a new VPS server that I configured with ispconfig and it returned error 500 without any reason
    [​IMG]
    [​IMG]
     
  9. minttux

    minttux Member

    I did it but not solved (it returns Error 500) without any log
    [​IMG]
    I can send vps info in your private message to check it yourself
     
  10. till

    till Super Moderator Staff Member ISPConfig Developer

  11. till

    till Super Moderator Staff Member ISPConfig Developer

    You can try to turn off custom error documents in the website. Might be that this is a virtual error thrown by WordPress and not the web server and by turning off own error documents, WordPress might be able to display the error message to you.
     
  12. minttux

    minttux Member

    Solved by disabling own error documents and I can't understand why it showed Error 500 when WordPress returned an error
     
  13. till

    till Super Moderator Staff Member ISPConfig Developer

    It showed 500 error page because WordPress returned an internal error code 5x series to Nginx, and therefore, Nginx displayed the standard error page for error 500 while Nginx itself has not thrown that error, it was thrown virtually by WordPress.
     

Share This Page