1

i tryed so much and followed countless guides for that problem but just cant find a solution, so i hope that you can find a problem in my configs or have a other idea what the problem could be.

Beside my planned webpage i run the AMP-Webinterface for server-administration on a supdomain amp.EXAMPLE.COM, on my debian10 server, and that always works like a charm, only my own test-php-site (see below) wont show correctly, i tested with a example html site and that works perfectly.

php8.0-fpm is installed and the only php version (had 7.3 too before and removed it already)

#######################################################

index.php

<html>
 <head>
  <title>PHP-Test</title>
 </head>
 <body>
 <?php echo '<p>Hallo Welt</p>'; ?>
 </body>
</html>

#######################################################

EXAMPLE.COM.conf

server {
    if ($host = www.EXAMPLE.COM) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = EXAMPLE.COM) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;  listen [::]:80;
    server_name EXAMPLE.COM www.EXAMPLE.COM;
    root  /var/www/EXAMPLE.COM;
    index index.php index.html index.htm index.nginx-debian.html;

         location / {
        location ~* \.php$ {
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_pass 127.0.0.1:9000;
            try_files $uri @yii =404;
        }
    } }

server {
    listen 443;     listen [::]:443;
    server_name EXAMPLE.COM www.EXAMPLE.COM;
    root  /var/www/EXAMPLE.COM;
    index index.php index.html index.htm index.nginx-debian.html;       

      location / {
        location ~* \.php$ {
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_pass 127.0.0.1:9000;
            try_files $uri @yii =404;
        }
    }


    ssl_certificate /etc/letsencrypt/live/EXAMPLE.COM/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/EXAMPLE.COM/privkey.pem; # managed by Certbot

}

#######################################################

nginx -t

nginx: [warn] conflicting server name "amp.EXAMPLE.COM" on [::]:443, ignored
nginx: [warn] conflicting server name "amp.EXAMPLE.COM" on 0.0.0.0:443, ignored
nginx: [warn] conflicting server name "amp.EXAMPLE.COM" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "amp.EXAMPLE.COM" on [::]:80, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Nginx Error log isnt showing any errors too, except the "conflicting server name thing"

#######################################################

php8.0-fpm is installed and working ("php-fpm" cant be found by systemctl, could this be a problem?)

systemctl status php8.0-fpm

● php8.0-fpm.service - The PHP 8.0 FastCGI Process Manager    Loaded: loaded (/lib/systemd/system/php8.0-fpm.service; enabled; vendor preset: enabled)    Active: active (running) since Tue 2021-03-16 14:08:33 UTC; 18h ago
     Docs: man:php-fpm8.0(8)  Main PID: 100460 (php-fpm8.0)    Status: "Processes active: 0, idle: 2, > Requests: 11, slow: 0, Traffic: 0req/sec"
    Tasks: 3 (limit: 9508)    Memory: 17.6M    CGroup: /system.slice/php8.0-fpm.service
           ├─100460 php-fpm: master process (/etc/php/8.0/fpm/php-fpm.conf)
           ├─100461 php-fpm: pool www
           └─100462 php-fpm: pool www

Mar 16 14:08:33 localhost systemd[1]: Starting The PHP 8.0 FastCGI Process Manager... Mar 16 14:08:33 localhost systemd[1]: Started The PHP 8.0 FastCGI Process Manager.

#######################################################

tail -f /var/log/nginx/error.log

[error] 129821#129821: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 217.254.148.38, server: EXAMPLE.COM, request: "GET / HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "EXAMPLE.COM"

#######################################################

Fantabaum
  • 11
  • 2
  • 1
    `netstat -tlnp | grep 9001` check if php-fpm listen 9001(the default is 9000). – LF00 Mar 17 '21 at 08:38
  • `tail -f /var/log/nginx/error.log` to see the 502 reason. – LF00 Mar 17 '21 at 08:38
  • Use `nginx -T` (uppercase `T`) to view the entire configuration across all included files and identify where the duplicate `server_name` directives are. Is Nginx reading a save file left behind by an editor? – Richard Smith Mar 17 '21 at 09:08

1 Answers1

0

Thank you i finally found the solution! breaksdownintearsofjoy

  1. Problem has been that fastcgi wasnt installed >_> For my debian 10 i just did: apt-get install fcgiwrap

  2. problem was the localhost ip it kinda didnt liked; so i just replaced "fastcgi_pass 127.0.0.1:9000;" with the complete dir of the php fpm sock "fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;"

Fantabaum
  • 11
  • 2