Apache no sirve a los hosts locales

Apache no sirve a los hosts locales

He configurado un servidor Apache en un servidor Linux Mint 21 alojado en VMWare, he seguido las instrucciones eneste blogpara ejecutar múltiples versiones de PHP (7.4 y 8.1).

Apache está funcionando bien y sirve páginas en localhost correctamente, pero los servidores virtuales simplemente agotan el tiempo de espera con "DNS_PROBE_FINISHED_NXDOMAIN". Estoy perplejo en cuanto a lo que estoy haciendo mal.

Aquí está el archivo de configuración para la versión PHP 7: –

<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>

Aquí está el archivo de configuración para la versión PHP 8: –

<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>

Los registros de errores muestran FPM para PHP7 disponible: -

[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

Los registros de errores también muestran FPM para PHP8 disponible: -

[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

Respuesta1

No pude hacer funcionar esta configuración, reinicié la VM y usé elinstrucciones aquípara configurar las dos versiones de PHP.

Para resumir:-

#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

Para cambiar de PHP 8.x a 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

Para cambiar de PHP 7.xa 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

información relacionada