I have two virtual hosts on an Ubuntu 18.04. server with apache 2.4. The first one has a codeigniter php application and works fine. In the second one only a html file can be displayed. The call of the simple php-file index.php with the content
<?php echo 'vh2 test'; ?>
leads to following error message:
Fatal error: Unknown: Failed opening required '/var/www/html2/index.php' (include_path='.:/usr/share/php') in Unknown on line
There are many posts about this error on stackoverflow. I have looked through almost all of them, but none of the solutions helped. Many of the answers refer to older apache versions. My php is version 7.2.
The configuration of the 2 virtual hosts:
Directories: /var/www/html1 /var/www/html2 The rights of folder and files are the same.
Configuration für virtual host 1 (okay)
<VirtualHost sidexxx1.de:80>
ServerAdmin webmaster@sidexxx1.de
DocumentRoot /var/www/html1
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Redirect permanent / https://sidexxx1.de
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost sidexxx1.de:443>
ServerAdmin webmaster@sidexxx1.de
ServerName sidexxx1.de
DocumentRoot /var/www/html1
<Directory /var/www/html1/>
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/sidexxx1.de.crt.pem
SSLCertificateKeyFile /etc/ssl/private/sidexxx1.de.key.pem
SSLCertificateChainFile /etc/ssl/certs/sidexxx1.de.ca.pem
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
</IfModule>
The configuration of vhost 2 is identical to vhost 1 except:
- domain sidexxx2.de instead of sidexxx1.de
- directoryname /var/www/html2 instead of /var/www/html1
No SELinux is installed. SSL works on both sides.
Why is php not displayed in virtual host 2?