Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I installed Apache successfully on a Windows 7, 32bit system. It showed "It works" in the webpage. I also configured <?php phpinfo(); ?>file as info.php. But when I tried to open http://localhost/info.php in the browser, all I get is <?php phpinfo(); ?>in plain text.

I restarted Apache server every time I made changes. Anyone can help with this?

share|improve this question

migrated from stackoverflow.com Nov 12 '11 at 0:43

This question came from our site for professional and enthusiast programmers.

4 Answers 4

Add the appropriate handlers, as you could've read in the manual:

You need to insert the following lines into your Apache httpd.conf configuration file to load the PHP module for Apache 2.x:

# 
LoadModule php5_module "c:/php/php5apache2.dll"
AddHandler application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir "C:/php"
share|improve this answer
    
I did exactly the same thing as you said, the result I got was as above, the plain text instead of php info. I'm using Apache 2.2 and php 5.3.8 –  manxing Nov 11 '11 at 14:12
    
you haven't PHP really, if you see php-page source as plain-text. Check all three strings above in httpd.conf (with your path) –  Lazy Badger Nov 12 '11 at 14:43
    
For Apache 2.2 you have to use php5apache2_2.dll (php5apache2.dll doesn't exist on distro). For Apache-integration you must install php-5.3.8-Win32-VC9-x86 PHP distro –  Lazy Badger Nov 12 '11 at 14:50

You have to configure PHP with Apache for it to work with php code. The easier course of action is to use something like http://www.wampserver.com/en/ . It will nicely and easily set things up for you, however at some point in time you will def need to dive into httpd.conf file and figure out how to manually setup PHP into Apache.

share|improve this answer

Are you sure your php5apache2.dll is actually in that path? It seems like a few years ago, I had to copy those from another directory in the PHP installation directory (though I don't remember what version of PHP I was working with at the time).

Aside: I would've posted this as a comment, but I don't have the rep yet.

share|improve this answer

Per this tutorial (step 4) try editing the doc_root line to point to the root folder of where you are serving PHP files from, e.g. doc_root = "C:\public_html". It should match the DocumentRoot path in your Apache config file.

Also, when you make changes to your Apache or PHP configs, you need to restart Apache for the changes to be loaded.

The tutorial I linked above has been my years-long guide for setting up and running the AMP stack on Windows, it's worth a look. Not the author, just a happy user.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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