Saturday, April 27, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 92663  / 1 Year ago, sat, april 15, 2023, 4:41:23

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

More From » apache2

 Answers
1

I found the solution here. It turns out I had to enable some modules...






Taken from this Stack Overflow answer by user1075581:






This finally put me on the right path:



http://www.linuxquestions.org/questions/linux-server-73/php-not-working-on-one-vhost-but-works-on-all-others-851093/



Here's the solution:



In the <Directory> section, I included these lines:



<IfModule sapi_apache2.c>
php_admin_flag engine on
</IfModule>
<IfModule mod_php5.c>
php_admin_flag engine on
</IfModule>


Or, a redacted copy/paste of the solution on my server:



<Directory "/var/www/vhosts/A2/httpdocs">
<IfModule sapi_apache2.c>
php_admin_flag engine on
</IfModule>
<IfModule mod_php5.c>
php_admin_flag engine on
</IfModule>

(Other configuration parameters)

</Directory>


[#27390] Sunday, April 16, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eeperant

Total Points: 39
Total Questions: 106
Total Answers: 117

Location: Finland
Member since Sat, Dec 5, 2020
3 Years ago
;