Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
How to setup php in all virtual hosts?

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?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!