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
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.
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>
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>
This helped my out a2enmod php5
, if the module does not exist reinstall lamp-server by typing apt-get install lamp-server^
In my case, the problem was fixed by running the following command:
apt-get install libapache2-mod-php
For my configuration I had to add this line to the virtualhost (inside <Directory>
):
AddType application/x-httpd-php .php