Jump to content

PHP pages display script instead, read and tried everything


Recommended Posts

My machine was reimaged and I had to reinstall everything. Now I can't get PHP to process any scripts. The scripts are displayed as if a text file. This morning I uninstalled PHP and Apache and reinstalled. My Apache config file has:

#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL

PHPIniDir "C:/Program Files/PHP/"

LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll"

#AddType application/x-httpd-php .php

#AddHandler application/x-httpd-php .php

#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL

 

I've tried with and without AddType and AddHandler.

 

I have Win XP SP3, Apache 2.2.15, and PHP 5.3.2 installed as Apache module. Also I have IIS 5.1 running on port 82. I need that for classic ASP pages. Everything was working fine before my machine was reimaged. Help please!

Link to comment
Share on other sites

These would be the minimum lines needed -

PHPIniDir "your_actual_path_here"
LoadModule php5_module "your_actual_path_here/php5apache2_2.dll"
AddType application/x-httpd-php .php

 

Did you stop and start the web server after making any changes so that they would take effect?

Link to comment
Share on other sites

Yes, I stopped and started the server each time. Just now I tried changing to CGI instead of Apache module. No difference.

 

The PHP extension does not seem to be recognized or it's being masked, but I don't see how. IIS is running on another PORT. All my ASP.NET applications run through the Apache server fine via mod_aspdotnet, so the Apache server is recognizing and processing different file extensions.

 

When I install PHP I don't use the IIS option but one of the Apache options.

Link to comment
Share on other sites

I've never had an issue with the MSI installer package before. I did try something which had an effect. I change the Apache config to the following:

 

#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL

PHPIniDir "C:/Program Files/PHP/"

LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll"

AddHandler application/x-httpd-php phpz php

#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL

 

This told it to use the file extension PHPZ in addition to PHP. That worked. If I rename a .php file to .phpz, the script runs properly. It won't run as .php though.

 

I will download the zipped version of PHP and see if that makes a difference. I don't think it will though.

Link to comment
Share on other sites

No. I have an application defined as follows. If I put the PHPZ file there it works.

 

#php

Alias /php "C:/websites/php"

<Directory "C:/websites/php">

    Options FollowSymlinks Indexes

    Order allow,deny

    Allow from all

</Directory>

 

Link to comment
Share on other sites

RESOLVED

 

I uninstalled PHP that was done via msi file, unzipped the PHP zip file to c:\php and placed the following in Apache config:

 

PHPIniDir "C:/php/"

LoadModule php5_module "C:/php/php5apache2_2.dll"

 

I had the AddHandler line too, but upon trying without it I left it commented out. Apache says all virtual paths are scripted by default which is why the AddHandler isn't necessary. Having Apache read PHP from c:\Program Files is identical to c:\php. As mentioned earlier the PHPZ extension was working so that proves PHP was working.

 

I like doing the zip version better because no install/uninstall is necessary. All that's required is to replace files at c:\php.

 

I don't know what fixed the problem but I'm not going to worry about it.

 

Link to comment
Share on other sites

The problem I was having was a result of pages being cached in the browser. It was only by chance I got it to work at all! I assume I just happened to refresh the page I was testing with, otherwise it wouldn't have worked. Following that some pages were working and others not. When I reset the cache everything worked.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.