Pre-requisites:
- Follow my instructions on installing Apache on Windows Vista
- And then follow my instructions on installing PHP on Windows Vista
Installing PHP with Apache on Windows Vista is a relatively simple task until you try an configure the settings in php.ini. Problems can occur and stem from the fact that when you install PHP and edit the php.ini file, you need to not only be logged in as Administrator, but run the installer and Notepad text editor as Administrator. The php.ini file also needs to be located in the Windows directory.
Below is an outline of the steps to get your PHP installation running and configured correctly.
- Run Notepad as Administrator. Go to All Programs > Accessories Right-click “Notepad” and select “Run as Administrator”. Open the php.ini file, in my case:
C:\PHP5\php.ini
- Edit the php.ini file as necessary, e.g.:
extension_dir = "C:\PHP5\ext" upload_max_filesize = 16M upload_tmp_dir = "C:\PHP5\upload" session.save_path = "C:\PHP5\session"
- Enable the extensions you need by deleting the semi-colon at the beginning of the line. For example, you will commonly need the following MySQL extensions:
extension = php_mysql.dll extension = php_mysqli.dll
- Save the edited php.ini file into your Windows directory. This is very important as Vista will not read the changes but will refer to the default settings.
- Check that the PHP directory has been added to your computers “Environment Variables”. Click Start, right-click on Computer, select Properties > Advanced > Environment Variables. Click on PATH and select Edit. If the PHP path is there, in my case “C:\PHP5\”, all is well, otherwise add the PHP path.
- System Properties:

- Environmental Variables

- Edit Environmental Variable - PATH

- System Properties:
- Open your Apache configuration file (httpd.conf). Ensure the following lines are present (at the bottom of the file):
LoadModule php5_module "C:\PHP5\php5apache2_2.dll" AddType application/x-httpd-php .php AcceptPathInfo on PHPIniDir "C:\Windows"
If there are additional
LoadModulelines, remove them, leaving only the one that relates to your version of Apache. - Find the DirectoryIndex in the Apache config and append
index.php, e.g.:<ifmodule dir_module> DirectoryIndex index.html index.php </ifmodule>
- Restart the Apache service.
- Create a index.php file in your webroot and add the following lines:
< ?php phpinfo(); ?>
- Navigate to the file (e.g. http://localhost/index.php) and you will be presented with all the PHP and server settings. You’re now good to go.
Tags: administrator, Apache, configure, installation, installing, PHP, problems, settings, solutions, Vista




















20 comments
Comments feed for this article
Trackback link
http://www.simonwhatley.co.uk/configuring-php-with-apache-on-windows-vista/trackback
20 February 2008 at 9:00 am
Simon
If you use the PHP 5 installer, you’ll notice that it uses the wrong type of slash on Windows!
For example, change “C:/PHP5/” to “C:\PHP5\” and everything works great.
29 March 2008 at 6:26 am
Mike
could you please explain more on
Enable the extensions you need by deleting the semi-colon at the beginning of the line. For example, you will commonly need the following MySQL extensions:
extension = php_mysql.dll
extension = php_mysqli.dll
because i cant find it, otherwise everything else is good.
2 May 2008 at 10:04 pm
Jesse
Thank you so much. I was beginning to see another two hours ahead, but your instructions spared me of it. thanks
14 May 2008 at 6:10 pm
Alan
I just want to point out that Apache v.2.2.8 keeped crashing with PHP 5.2.6
Install earlier version of PHP and thing will sing like a bird..
20 June 2008 at 4:31 am
sergio
what is my webroot or were is it.
20 June 2008 at 9:51 am
Simon
@sergio your webroot is wherever you set it up in Apache.
Mine happens to be C:\WebRoot.
The default for Apache on Windows is:
C:\Program Files\Apache Software Foundation\Apache2.2\htdocs
If you want to amend the location, look in the httpd.conf file for DocumentRoot and change it to the location of your webroot. You will also need to update the following code
20 June 2008 at 2:08 pm
sergio
Hi again all is set, the apache works when a put http://localhost/ it returns “it works”. But my php when a put http://localhost/index.php, it returns an totally empty blank page, also when a create a html file, it ignores my php code ( writing what is in between the start stop php tags as just as it is written, this way a can only create html. Thats not good for me because i need it to practice to pass exams at uni. Of course there is always linux but a totaly dont like it due to its poor user friendly methods, and also have problems installing php.
By the way thanks allot for your help and hope that you can take me out of this whole.
20 June 2008 at 2:16 pm
Simon
@sergio you need to make sure that the index.php file is referenced in the Apache configuration file:
20 June 2008 at 4:07 pm
sergio
its still the same thing, if that line index.php is not present as shown above it occurs an error on the webpage, but in my case using what is shown above there is no error just a blank page I am starting to think that the php install must be damaged, going to download again and retry.
Thanks for your atention, ill give feedback when finished.
20 June 2008 at 4:20 pm
Simon
@sergio the Apache httpd.conf will need the php configuration lines. You will know if PHP is correctly installed because, when you open the Apache Services Monitor screen (double click on the feather icon in the system tray) you see PHP/5.2.x written in the monitor’s status bar.
You *may* need to locate the php.ini file in the Windows directory rather than the PHP directory, although this is not always the case!
(My work machine has the php.ini in the PHP directory, whilst my home machine would only work with it in the Windows directory. Both are Vista Business edition)
Try using PHP 5.2.5, not the latest release. Don’t install all the extensions, only those that are needed; commonly these are the MSSQL, MySQL and GD extensions.
Once you’ve installed a couple of extensions you can go back afterwards to install the others, since they will all be on your server. To add extra extensions is simply a case of editing the php.ini file with the extension’s name eg. extension=php_gd2.dll;
Every change requires an Apache service restart.
23 June 2008 at 12:15 pm
sergio
Hi again good afternoon, just came to give you the update of the installation, I gave up so what i did, searching in the net i tried out many other programs some just totally crashed, until i came upon php designer 2007 free for non comercial use, after install just had to direct it to the php-win.exe file in its program options, of the prevous php.msi setup just as you explained. It is so easy to use that it gives me the creaps after having to learn c language, its something to forget.
thanks for the tips especialy that windows command line to install msi file (msiexec /i filename.msi), and of course for that experience on playing around with the config file and the php ini file.
Compliments
sérgio santos
23 June 2008 at 5:40 pm
sergio
Hi again just not to show that i am not a quitter i retried and found where i mistake, it was on the backslash in the config file of the apache. Now it works just has you said.
23 June 2008 at 10:23 pm
Simon
@sergio good to see that your perseverance has been rewarded.
1 July 2008 at 1:29 am
jeff
I am having a similar problem to what sergio experienced. PHP is installed. I have confirmed via command line prompts that it is running. When I look at the Apache monitor I see the PHP 5.2.6.
When I run the test page with a phpinfo(); command I get nothing back. I have my php.ini file in the windows and Program Files\PHP directories.
Any help would be appreciated.
1 July 2008 at 8:46 am
Simon
@Jeff the php.ini file need only be in one directory, either the PHP or Windows directory. I would favour the PHP directory.
Make sure the path in your httpd.conf directory points to the correct file. (Details can be found in the above post).
Make sure the index.php file, in which you have the
<?php phpinfo(); ?>is in the correct location. (See my comments above).Make sure your PHP install has the minimum installed extensions required by your apps. These tend to be the MySQL and GD libraries. You can always add/uncomment additional libraries in the future if and when needed.
1 July 2008 at 11:29 am
jeff
Thanks. I am now able to run a file with the .php extension. When I try to run the following I just get the HTML portion. The PHP code does not seem to execute.
Using PHP and HTML Together
Using PHP & HTML Together
Here is your PHP info:
1 July 2008 at 11:33 am
jeff
The system parsed the code…
2 July 2008 at 3:07 am
jeff
The code works and the php output is displayed only if the file suffix is php and the file type is .php. If it is .html the php code does not execute. It isn’t a big deal, but if you know what is going on and how to correct it it would be great.
Thanks for all your help. It has saved me countless hours!
2 July 2008 at 9:17 am
Simon
@Jeff the .php extension tells the webserver that PHP needs to render the content on the page, even if it doesn’t contain any PHP code. If you simply name the files with the .html extension, PHP will not render the page so any code wrapped in
<?php ?>will be rendered simply as text.4 July 2008 at 3:02 pm
Jason Smith
Is anyone else having trouble with apache ignoring changes to httpd.conf? I can add a line randomly in the file “THIS ISN’T SUPPOSED TO BE HERE” and it will fail the test apache config thing, but apache completely ignores it. I’ve changed Documentroot with no effect as well so it’s not as if I’m just getting subtleties.
Is there some way to verify that it is using the conf file at all? I get the PHP 5 byline in the status bar of monitor, so I know something is working right…