Wednesday, July 1, 2015

[PHP] PHP not working | Code not being executed by apache.

Hi,

I had this problem yet to be resolved. I tried easyphp, zpanel but php did not work for me. I could see my php code in page source in browser. My apache was actually not executing php code as php, rather it was taking as simple html.

To solve this problem, follow the steps below.
1. Check if php is really installed and available. Open command prompt anywhere and execute php -version

This should return something like this.


If you're unable to see, add php to path.

2. Check if php module is added in httpd.conf of your apache. Something like this should be present
LoadModule php5_module "C:/zpanel/bin/php/php5apache2_4.dll"
PHPIniDir "c:/zpanel/bin/php" 

3. Check if AddType is added and uncommented in httpd.conf. If this is not present, add it.
AddType application/x-httpd-php .php

Apart from these, just check the file extension, it should not .php and not accidently saved as .php.txt. And if you're using short tags <? then short tags should be allowed. To allow php short tags follow this post

Hope this helps.

Until next time. C ya.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.