Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

170
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda