I'm not positive if this is a programming question or a server question, but I'm leaning towards server. I've been in the process of moving a webpage (basic php backed by a MySQL database) from an Ubuntu server to an OSX server. I've enabled the php module in the apache configuration (httpd.conf) and created an php.ini file in /etc and php seems to be working - just not with the old webpage.
Basically I set up the web page on the local subnet for testing purposes (it's hosted at 10.x.x.x) and pointed the web server to a directory where I copied all the files from the other server. When I direct Safari to the address 10.x.x.x it correctly finds and displays index.php, BUT it doesn't execute the script it just dumps the contents to the browser.
At that point I thought I had incorrectly setup php, so I created the clasic info.php just containing
<?
phpinfo();
?>
and to my surprise it ran correctly (from 10.x.x.x/info.php).
Which made me think there must be a problem with the code itself. Since the code currently works on the Ubuntu server and there haven't any changes I check the versions of php. The old server is using 5.2 and the OSX server is running 5.3. It's possible that's the problem, but it doesn't make much sense because I don't think that much has changed, and the php for this website is VERY basic. Further evidence that it's a code issue is that I get the same behavior from the command line when I directly execute index.php and info.php via php index.php
and info.php
.
However, I'm still leaning towards the idea that the problem is on the OSX server and not in the programming, because if it were a problem with the php (due to versions or some syntax error) wouldn't I get an error message when trying to execute the script instead of the file just being treated as text?
What do you think is going on? Have I just lost my mind :). Any help on getting these php files executing is greatly appreciated. Thanks!!
IIRC short open tags are disabled by default on OS X. While your info.php test seems to indicate they're enabled on your setup, I'd still suggest editing at least one of your files to use long tags (i.e.
<? ?>
-><?php ?>
) and see if that makes any difference.