0

My WAMP server is not executing PHP. I have already tried the following things:

  • restarted just Apache
  • restarted all WAMP services
  • restarted the WAMP application
  • restarted my whole system
  • renamed the file
  • placed the file in the root direcory
  • my file is named index.php, its not a txt file
  • I am accessing it as localhost/phppractice/index.php
  • Tried on different browsers (Chrome, FF, Opera)

This is my code, which I am assuming is correct:

<?php phpinfo(); ?>

Simple as that. I have also tried to run it as:

<html>
<head>
<title>TEST</title>
</head>
<body>
<?php phpinfo(); ?>
</body>
</html>

And to substitute the phpinfo() with hello world. The result is the same - a blank page. No code, no result of the code, nothing, just a blank page. I have totally no idea what am I doing wrong.

  • Did you enable php in your apache configs? thesitewizard.com/php/install-php-5-apache-windows.shtml – Kruug Jun 21 '13 at 15:48
  • Is apache set up to map your phppractice/ folder correctly? – MattDMo Jun 21 '13 at 15:48
  • Also, did you check the server logs to see if there is an error someplace? – MattDMo Jun 21 '13 at 15:49
  • @Kruug - yes, I have Apache 2.2.22 and LoadModule php5_module "c:/wamp/bin/php/php5.3.13/php5apache2_2.dll" in the config, so it should be ok. – user232865 Jun 21 '13 at 15:55
  • 1
    @SBI Wamp sets Apache/MySQL/PHP up automatically. Its a one click Apache web environment. So dont fiddle with the DocumentRoot parameter. – RiggsFolly Jun 28 '13 at 11:51
1

The code should be correct with just the <?php phpinfo(); ?> so I'm assuming the issue would be with a configuration setting.

Since it looks like you already named the file index.php, I would double check:

  1. That the files are in the proper web root directory, and
  2. The WAMP configuration is selecting that directory for web root.

However, if those two checks turn out clean and since you're on Windows, I would suggest that you still double check the file extension to ensure that it's a .php and not a text file by right clicking on the file and selecting properties (not by what it says in the file explorer). Depending on the program you are using, it still may default to saving as a .txt file even if you put .php at the end of your file name (Notepad can be bad about this).

Another option, if you're only doing some basic PHP development is MAMP. I've personally found it easier to use than WAMP, but that's just my experience and I'm sure there may be some that disagree with me.

0

Make sure that the filename of the script you are running has an extension of .php

If you use a .html extension it will not be passed to the PHP interpreter for compilation and execution.

-2

You need just to put those 3 lines in your httpd.conf & httpd-vhosts.conf files:

1. C:\wamp\bin\apache\Apachex.x.xx\conf\extra\httpd-vhosts.conf

2. C:\wamp\bin\apache\Apachex.x.xx\conf\httpd.conf

DirectoryIndex index.php index.php3 index.html index.htm

AddType application/x-compress .Z

AddType application/x-gzip .gz .tgz

AddType application/x-httpd-php .php

AddType application/x-httpd-php .php3

ForceType application/x-httpd-php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.