Ausführung bei 404 mit PHP-Seiten auf Nginx

Ausführung bei 404 mit PHP-Seiten auf Nginx

Ich bin ziemlich neu im Serverbereich und richte meinen ersten Webserver mit Nginx PHPMyadmin(sowie SSL und Wordpress) ein. Das Betriebssystem, an dem ich arbeite, ist ein Debian 10 DockerImage.

Ich folgeDasTutorial zum Erstellen eines LEMPStacks. Ganz am Ende überprüfe ich, ob es PHPtatsächlich funktioniert, indem ich eine php.info-Seite erstelle und sie anschließend ausführe (nginx- und php-Dienste werden gestartet). Ich lande jedoch immer wieder auf einer 404-Seite. Wenn ich phpinfo()in die Befehlszeile meines Bildes tippe, erhalte ich alle Informationen korrekt. Hier sind meine Codes.

example.combefindet sich/etc/nginx/sites-verfügbar/

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    include snippets/self-signed.conf;
    include snippets/ssl-params.conf;

    root /var/www/example.com;
    index index.php index.html index.htm;

    server_name example.com www.example;

    location / {
        try_files $uri $uri/ =404;
        autoindex on;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
    }
}

server {
    listen 80;
    listen [::]:80;

    server_name example.com www.example.com;

    return 301 https://$server_name$request_uri;
}

server {
   listen 80;
   server_name pma.com www.pma.com;
   root /usr/share/phpMyAdmin;

   location / {
      index index.php;
   }

   location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
      access_log off;
      expires 30d;
   }

   location ~ /\.ht {
      deny all;
   }

   location ~ /(libraries|setup/frames|setup/libs) {
      deny all;
      return 404;
   }

   location ~ \.php$ {
      include /etc/nginx/fastcgi_params;
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin$fastcgi_script_name;
   }
}

info.phpbefindet sich/var/www/beispiel.com/

<?php
phpinfo();
?>

Ich verwende eine Shell-Skriptdatei, um zur Build-Zeit alles auf meinem Docker-Image zu installieren.

Skript

## Packages Installation ##
apt-get update -y && apt-get upgrade -y && apt-get install -qq nginx \
php-json php-xmlrpc php-xml php-soap php-fpm php-mysql php-mbstring \
mariadb-server \
wordpress \
vim wget
###########################

# wget https://files.phpmyadmin.net/phpMyAdmin/4.9.0.1/phpMyAdmin-4.9.0.1-all-languages.tar.gz
# tar -xzvf phpMyAdmin-4.9.0.1-all-languages.tar.gz

## Apache2 Removal ##
apt-get remove --purge apache2 -y
#####################

# SSL Configuration ##
service mysql start
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout \
/etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt \
-subj "/C=BE/ST=BRUSSELS CITY/L=Brussels/O=19 Coding School/OU=Lacollar/CN=172.17.0.2/[email protected]"
openssl dhparam -out /etc/nginx/dhparam.pem 2048
#snippets creation
#conf file editing
######################

## PHP Processor Configuration on Nginx ##
# mv /var/www/example.com /var/www/example.com.bak
mkdir /var/www/example.com
cp /var/www/html/index.nginx-debian.html var/www/example.com/index.nginx-debian.html
chown -R $USER:$USER /var/www/example.com
#copy example onto sites-available
chmod 755 /etc/nginx/sites-available/example.com
ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled
nginx -t
##########################################

# ## phpMyAdmin Installation ##
rm /phpMyAdmin-4.9.0.1-all-languages.tar.gz
# mkdir /usr/share/phpMyAdmin
mv /phpMyAdmin-4.9.0.1-all-languages /usr/share/phpMyAdmin
mv /usr/share/config.inc.php /usr/share/phpMyAdmin/
#save config.sample, copy config
mysql < /usr/share/phpMyAdmin/sql/create_tables.sql -u root
mysql -u root -e "GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'pma'@'localhost' IDENTIFIED BY 'pmapass'"
mysql -u root -e "FLUSH PRIVILEGES"
#copy phpmyadmin.conf onto /etc/nginx/conf.d
mkdir /usr/share/phpMyAdmin/tmp
chmod 777 /usr/share/phpMyAdmin/tmp
chown -R www-data:www-data /usr/share/phpMyAdmin
mysql -u root -e "CREATE DATABASE app_db"
mysql -u root -e "GRANT ALL PRIVILEGES ON app_db.* TO 'app_user'@'localhost' IDENTIFIED BY 'password'"
mysql -u root -e "FLUSH PRIVILEGES"
# #############################

# IP Address display
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

rm /tmp/configuration.sh

Da ich dachte, das Problem könne nicht an PHP, sondern an etwas anderem liegen, habe ich auch versucht, phpMyadmin einzurichten (und dann nginx neu zu starten). Ich kann nicht darauf zugreifen, was mich vermuten lässt, dass das Problem an PHP liegt.

Jede Hilfe ist willkommen.

verwandte Informationen