Apache Virtual Host not parsing PHP

后端 未结 10 1192
日久生厌
日久生厌 2020-12-05 23:42

I decided to enable virtual hosts on my Apache server, and chose to make it port-based.

First thing I did, of course, was RTM. I followed the instructions found her

相关标签:
10条回答
  • 2020-12-06 00:18

    This could also be due to php files using short php tags <? instead of <?php. By default, short tags are not enabled in the php.ini config file.

    0 讨论(0)
  • 2020-12-06 00:25

    I'll have to load up a centos vm to check the apache conf but on ubuntu I have a lot more info in my config under the virtualHost

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>
    
    0 讨论(0)
  • 2020-12-06 00:26

    In my case it was a default setting in php.conf. It says:

    # Running PHP scripts in user directories is disabled by default
    

    Check your php.conf (for PHP 7.1 it's accordingly /etc/apache2/mods-enabled/php7.1.conf) and comment the mentioned lines:

       root@zxxxx:/home/pxxx/public_html# vi /etc/apache2/mods-enabled/php5.conf
       # To re-enable PHP in user directories comment the following lines
       # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
       # prevents .htaccess files from disabling it.
           <IfModule mod_userdir.c>
            <Directory /home/*/public_html>
                ***php_admin_flag engine On*** -> Turn this option ON
            </Directory>
        </IfModule>
    
    0 讨论(0)
  • 2020-12-06 00:30

    This helped my out a2enmod php5, if the module does not exist reinstall lamp-server by typing apt-get install lamp-server^

    0 讨论(0)
  • 2020-12-06 00:31

    In my case, the problem was fixed by running the following command:

    apt-get install libapache2-mod-php
    
    0 讨论(0)
  • 2020-12-06 00:35

    For my configuration I had to add this line to the virtualhost (inside <Directory>):

    AddType application/x-httpd-php .php
    
    0 讨论(0)
提交回复
热议问题