Forum

PHP runs on localhost but not from other machine

Patrick
31 May 2010, 14:06
Hello,

I have installed Hiawatha and PHP in a Puppy Linux machine to have a web server.

The phpinfo page displays well when I access it from http://localhost on the Linux machine but not from another machine : it displays the content of the PHP file instead of the result of the phpinfo() function :

<?php
phpinfo();
?>


Thanks for the help.

Patrick

Hiawatha version: 6.16
Operating System: Puppy Linux 4.3.1
Hugo Leisink
31 May 2010, 15:44
It's not possible that Hiawatha shows the PHP output for one client and the PHP source for another client. No code to do such kind of selection is present in Hiawatha. Are you sure you're connecting to one and the same web server from both clients?
Patrick
31 May 2010, 16:12
Thanks for the quick answer.

Yes, it is the same web server : the phpinfo page displays correctly when I show it locally (by http://localhost) but shows the source code of the PHP file when I connect to the web server from another machine on my intranet.

I think it is a problem with the configuration of the FastCGI access : it seems that the PHP interpreter is executed only when the access is local but not when the access is remote => the content of the file is displayed when the PHP interpreter is not called.

I have modified the file "/etc/hiawatha/hiawatha.conf" to substitute the adresse "127.0.0.1" by the IP adress of my machine in the parameter "ConnectTo" of the FastCGIserver section in this file but it doesn't solve the problem (even after stopping and restarting the web server).

Patrick
Hugo Leisink
31 May 2010, 16:53
It's probably an incorrect virtual host configuration. Can you show me your configuration file? I think what happens is that a different virtual host is selected when connected from localhost than from a remote machine. Remember that the hostname used in the URL is used to find the right virtual host section.
Patrick
1 June 2010, 09:42
You have found the problem : I didn't declare a second VirtualHost configuration for the access with the IP address of the server from another machine on my network.

I just copied in "/etc/hiawatha/hiawatha.conf" the configuration of the VirtualHost named "localhost" into a new VirtualHost named with the IP address of the machine and restarted hiawatha : my web site is now also visible from my Intranet.

Thanks a lot

Patrick
Hugo Leisink
1 June 2010, 11:29
Instead of using two virtual hosts, you can also add the hostname of the second one to the first.
VirtualHost {
Hostname = hostname1, hostname2, hostname3
...
}
This topic has been closed.