Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wamp Server isn't executing php code

My php code is not executed when I access the root directory with

http://localhost:8080/sample.html

The code I want to run is:

<?php phpinfo(); ?>

and I tried also the following:

  • Restarted all services several times including putting Wamp Server online
  • Changing the listening port in httpd.conf to 8080 and configuring Skype to accept 80 and 443 ports

Could it be that some firefox extensions are blocking php-execution?

All I get is the php code exactly like I wrote it.

like image 509
Stephen Younger Avatar asked May 15 '12 12:05

Stephen Younger


1 Answers

You're trying to execute PHP in an ".html" file. You have to edit the PHP handler in the apache config to make it process whatever file extension you want it to. Look for "AddType application/x-httpd-php .php" in your Apache configuration file (somewhere like 'wamp/apache/conf/httpd.conf') then just add " .html" after ".php". The line should look like this now:

AddType application/x-httpd-php .php .html

PHP should now execute any code it finds in files with ".php" and ".html" extensions.

Edit: Or as someone suggested above, just rename your file "sample.php" and it'll be processed.

like image 128
Nicolas BRERO Avatar answered Sep 23 '22 13:09

Nicolas BRERO