Apache bedient keine lokalen Hosts

Apache bedient keine lokalen Hosts

Ich habe einen Apache-Server auf einem von VMWare gehosteten Linux Mint 21-Server eingerichtet. Ich bin den Anweisungen unter gefolgtdieser Blogum mehrere PHP-Versionen (7.4 und 8.1) auszuführen.

Apache läuft einwandfrei und stellt Seiten auf dem lokalen Host bereit, aber die virtuellen Server melden sich mit „DNS_PROBE_FINISHED_NXDOMAIN“. Ich weiß nicht, was ich falsch mache.

Hier ist die Konfigurationsdatei für die PHP 7-Version: -

<VirtualHost *:80>
ServerAdmin [email protected]
ServerName legacy.local
DocumentRoot /var/www/legacy.local
DirectoryIndex info.php

<Directory /var/www/legacy.local>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

<FilesMatch \.php$>
# From the Apache version 2.4.10 and above, use the SetHandler to run PHP as a fastCGI process server
SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
</FilesMatch>

ErrorLog ${APACHE_LOG_DIR}/legacy.local_error.log
CustomLog ${APACHE_LOG_DIR}/legacy.local_access.log combined
</VirtualHost>

Hier ist die Konfigurationsdatei für die PHP 8-Version: -

<VirtualHost *:80>
ServerAdmin [email protected]
ServerName new.local
DocumentRoot /var/www/new.local
DirectoryIndex info.php

<Directory /var/www/new.local>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

<FilesMatch \.php$>
# From the Apache version 2.4.10 and above, use the SetHandler to run PHP as a fastCGI process server
SetHandler "proxy:unix:/run/php/php8.1-fpm.sock|fcgi://localhost"
</FilesMatch>

ErrorLog ${APACHE_LOG_DIR}/new.local_error.log
CustomLog ${APACHE_LOG_DIR}/new.local_access.log combined
</VirtualHost>

Die Fehlerprotokolle zeigen, dass FPM für PHP7 verfügbar ist: -

[08-Dec-2022 13:20:36] NOTICE: fpm is running, pid 801
[08-Dec-2022 13:20:36] NOTICE: ready to handle connections
[08-Dec-2022 13:20:36] NOTICE: systemd monitor interval set to 10000ms

Die Fehlerprotokolle zeigen, dass FPM auch für PHP8 verfügbar ist: -

[08-Dec-2022 13:20:36] NOTICE: fpm is running, pid 821
[08-Dec-2022 13:20:36] NOTICE: ready to handle connections
[08-Dec-2022 13:20:36] NOTICE: systemd monitor interval set to 10000ms

Antwort1

Ich konnte diese Konfiguration nicht zum Laufen bringen, ich habe die VM zurückgesetzt und dieAnleitung hierum die beiden PHP-Versionen einzurichten.

Um zusammenzufassen:-

#Set up default Web Server with PHP 8.x
sudo apt-get install -y lamp-server^
#Add PHP 7.x
sudo add-apt-repository -y ppa:ondrej/php
sudo apt update -y
sudo apt install -y php7.4

So wechseln Sie von PHP 8.x zu 7.x: -

sudo a2dismod php8.1
sudo systemctl restart apache2
sudo systemctl status apache2
sudo a2enmod php7.4
sudo systemctl restart apache2
sudo systemctl status apache2

So wechseln Sie von PHP 7.x zu 8.x: -

sudo a2dismod php7.4
sudo systemctl restart apache2
sudo systemctl status apache2
sudo a2enmod php8.1
sudo systemctl restart apache2
sudo systemctl status apache2

verwandte Informationen