So I setup my server using this tutorial, and when the test.php file works with no problem when I enter the address using my server's IP as
http://1.2.3.4/test.php
However, if I use virtualhosts, the browser just offers to download the file rather than executing it. So this:
http://blog.mydomain.com/test.php
offers to download the file rather than executing the script.
The code I use in /etc/apache2/apache2.conf for virtual hosts is the following:
Include /etc/phpmyadmin/apache.conf
Include /etc/apache2/mods-available/php5.conf
<VirtualHost *:80>
DocumentRoot /path/to/vhosts/folder1
ServerName www.mydomain.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /path/to/vhosts/folder2
ServerName blog.mydomain.com
</VirtualHost>
NameVirtualHost *:80
Though I have to say that when I restart the apache2 server I get a warning message:
[....] Restarting web server: apache2
[Sun Jan 19 13:33:40 2014] [warn] NameVirtualHost *:80 has no VirtualHosts ... waiting [Sun Jan 19 13:33:41 2014] [warn] NameVirtualHost *:80 has no VirtualHosts
/etc/apache2/
.