PHP Homepage Downloading instead of executing

Discussion in 'Server Operation' started by girthh, Dec 15, 2019.

  1. girthh

    girthh New Member

    SOLVED:: SEE BELOW

    (Perfect server tutorial, Debian 10, ISPconfig(3.1), NginX(1.14), Postfix(3.4.7), Roundcube, Dovecot(2.3.4.1), PHP(7.3), Digital Ocean hosting, and lots of altering/tinkering)

    Some sites on ISPConfig have Wordpress, others do not: All sites trying to download php homepage when visiting!
    Maybe a server block issue? Location directive?


    Common Server block settings:
    (this one in particular is wordpress website)
    Code:
    server {
            listen DIGITAL_OCEAN_IP:80 http2;
            listen [DIGITAL_OCEAN_IP]:80 http2;
            listen DIGITAL_OCEAN_IP:443 ssl http2;
            listen [DIGITAL_OCEAN_IP]:443 ssl http2;
    
            ssl_certificate /var/www/clients/client0/web2/ssl/MYDOMAIN-le.crt;
            ssl_certificate_key /var/www/clients/client0/web2/ssl/MYDOMAIN-le.key;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/ssl/dhparams4096.pem;
    ssl_ciphers EECDH+AESGCM:EDH+AESGCM:!aNULL:!MD5;
    ssl_ecdh_curve secp384r1;
    ssl_session_timeout  10m;
    ssl_session_cache shared:SSL:10m;
    ssl_session_tickets off;
    ssl_stapling on;
    ssl_stapling_verify on;
    resolver 8.8.8.8 8.8.4.4 valid=300s;
    resolver_timeout 5s;
    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
    add_header X-Frame-Options DENY;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
    
            server_name MYDOMAIN www.MYDOMAIN;
    
            root   /var/www/MYDOMAIN/web/;
    
            if ($scheme != "https") {
                rewrite ^ https://$http_host$request_uri? permanent;
            }
    
    
            index index.html index.htm index.php index.cgi index.pl index.xhtml;
    
    
    
            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;
          }
            location = /error/401.html {
                internal;
            }
            location = /error/403.html {
                internal;
            }
            location = /error/404.html {
                internal;
            }
            location = /error/405.html {
                internal;
            }
            location = /error/500.html {
                internal;
            }
            location = /error/502.html {
                internal;
            }
            location = /error/503.html {
                internal;
            }
    
            error_log /var/log/ispconfig/httpd/MYDOMAIN/error.log;
            access_log /var/log/ispconfig/httpd/MYDOMAIN/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/client0/web2/web//stats/.htpasswd_stats;
            }
            location ^~ /awstats-icon {
                alias /usr/share/awstats/icon;
            }
    
            location ~ \.php$ {
                           include /etc/nginx/fastcgi_params;
                            fastcgi_pass unix:/var/lib/php7.3-fpm/web2.sock;
                            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            }
            location @php {
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass unix:/var/lib/php7.3-fpm/web2.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
            }
            location / {
                            try_files $uri $uri/ /index.php?$args;
            }
    location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|
    xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|js|css)$ {
                            access_log off; log_not_found off; expires max;
            }
    }
    
    Non-Wordpress Server Block:
    Same as above, with only php locations directives at bottom as shown:
    Code:
    ..........
            location ^~ /awstats-icon {
                alias /usr/share/awstats/icon;
            }
    
            location ~ \.php$ {
                try_files /c243f0ea139c8c1751da3b1ba7ed918e.htm @php;
            }
    
            location @php {
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass unix:/var/lib/php7.3-fpm/web14.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
            }
    
     
    Last edited: Dec 15, 2019
  2. girthh

    girthh New Member

    UPDATE:: SOLVED

    http2 cannot be on listen directives that are not ssl.
    I used the master file for nginx blocks that is built in with ISPconfig and ran an ISPconfig RESYNC to resync all websites' server blocks.
    Problem is gone.

    For more information about how to update all server blocks at once with ISPconfig, browse the forums, or just buy the ISPconfig manual!
     

Share This Page