Blogvaria

This page is brought to you by Blogvaria (http://blog.evaria.com).

To obtain more information, ask questions and interact please visit our website.

Back to Blogvaria landing page
Feedback
Subscribe
   
Blogvaria

 

The personal pages

How to install PHP5 on Windows

TrackBack | Filed by Thomas under Internet stuff, Programming | Post popularity 33%

This article is a quick guide to getting PHP 5 running on your Windows machine (be it Windows 98/Me or Windows NT/2000/XP/2003). Note! I advise you remove all files like php.ini and PHP related DLLs from the Windows SYSTEM folder before moving on with a new PHP installation.

1. Download the PHP binaries

PHP is free and comes complete with the source code. If you are not interested in hacking the PHP source code, you can simply download the Windows binaries. Both the binaries and the source code can be found at the PHP website. At the time I wrote this, the relevant PHP binary to download comes in a zip file (PHP 5.1.3 zip package). The Windows installer version does not include the binaries to run PHP5 as an Apache module.

2. Installing/Upgrading PHP5

Installation is actually trivial.

  • If you are upgrading stop the Apache windows service before you continue and rename your current php5 dir to something like php5_backup, just in case something goes wrong.
  • Create a directory for PHP5 on your computer. For the purposes of this article, I will assume that you created C:\php5.
  • Extract all the files to this directory, sometimes they’ll be placed in a subdir called php-5.x.x-Win32 (when using WinRAR). Move all the files in this subdir to php5 and delete subdir php-5.x.x-Win32

3. Configuring PHP5

Inside the php5 directory you’ll find to files called php.ini-dist and php.ini-recommended. Open the last one in a text-editor (Notepad) and search for and replace (where needed) the following:

  • short_open_tag set to short_open_tag = On if you have tags on the form <? …
  • error_reporting set to error_reporting = E_ALL & ~E_NOTICE
  • register_globals set to register_globals = On if your scripts doesn’t work as intended, else leave off.
  • register_argc_argv set to register_argc_argv = On if your scripts passes information in strings (index.php?var1=value1&var2=value2)
  • doc_root set to the path to your Apache web directory, e.g. doc_root = C:\Apache2\htdocs (normally htdocs)
  • extension_dir set to extension_dir = “C:\php5\ext” (More info about useful extensions will follow)
  • SMTP set to SMTP = smtp.yourISP.com
  • All done – Save your new ini file as php.ini to the main directory C:\php5

4. Configure Your Apache Web Server

If you want PHP to work with your Apache server, you will need to modify your Apache configuration file to load it. Naturally, you will need to have already installed Apache on your machine and configured it. Please read our tutorial on how to install Apache on Windows if you haven’t already.

To configure Apache to load PHP5 as a module to parse your PHP scripts, use a text editor to open the Apache configuration file, httpd.conf, typically found in C:\Apache2\conf.

Next, add the following lines at the bottom of this file:

# For PHP 5 do something like this:
LoadModule php5_module "c:/php5/php5apache2.dll"
AddType application/x-httpd-php .php .php3 .phps

# configure the path to php.ini
PHPIniDir "c:/php5"

To configure Apache to load PHP5 as a CGI-Binary to parse your PHP scripts add this instead:

# For PHP 5 do something like this:
ScriptAlias /php/ "c:/php5/"
AddType application/x-httpd-php .php .php3 .phps
Action application/x-httpd-php "/php/php-cgi.exe"

Note! By using the CGI setup, your server is open to several possible attacks. Please read PHP’s CGI security section to learn how to defend yourself from those attacks.

Now all that remains is to add some variations of index files to the DirectoryIndex. Replace the DirectoryIndex line with the following:

DirectoryIndex index.htm index.html index.php index.html.var

Note! By changing the order you can make your server parse index.php before index.htm like this:

DirectoryIndex index.php index.html index.htm index.html.var

You may off course add more filetypes/extensions as well, e.g. index.phtml, index.shtml, index.php3 or whatever you use.

5. Testing Your PHP5 Installation/Upgrade

Create a PHP file with the following line:

<?php echo phpinfo() ?>

Save the file as phpinfo.php (or any other name that you fancy, but with the “.php” extension) into your Apache htdocs directory.

Next, restart your Apache server so that it can read the new configuration directives you placed into httpd.conf. Open your browser, and access the file you just created by typing http://localhost/phpinfo.php into your browser’s location bar. You should see an entire pageful of information about your PHP setup.

Congratulations – you have successfully installed PHP and configured Apache to work with it. You can also use this same file, phpinfo.php, to find out more about how your web host has set up his php.ini so that you can duplicate it on your local machine.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • BlinkList
  • blogmarks
  • del.icio.us
  • De.lirio.us
  • digg
  • Furl
  • NewsVine
  • Netscape
  • Reddit
  • Spurl
  • SphereIt
  • Technorati
  • YahooMyWeb
  • DZone
  • feedmelinks
  • Linkter
  • Ma.gnolia
  • Slashdot
  • StumbleUpon
  • TailRank
  • co.mments
01

Blogvaria » How to install Apache on Windows said,

May 2, 2006 @ 3:05 pm

[...] More information on how to edit the configuration files in the conf subdirectory will follow with related articles as how to install PHP5 and MySQL5 on Windows, and also how you create virtual web directories and aliases.   [...]

02

Blogvaria » Upgrading to Apache 2.2 said,

January 3, 2007 @ 12:25 pm

[...] How to install PHP 5 on Windows [...]

03

Blogvaria » Your site’s page rank in Google™ said,

January 25, 2007 @ 11:33 am

[...] point of view you might say I got lucky since I’ve written stuff about Skype, iPhone, Apache, PHP and other stuff that a lot of people take interest in. On the other side so have a bunch of other [...]

04

Blogvaria » Update PHP5 in 30 seconds said,

June 22, 2007 @ 6:52 pm

[...] Note! These instructions are only applicable if you are running a local web server on Windows AND followed my instructions on how to install PHP5 on windows. [...]

05

Blogvaria » End of the road for PHP4 said,

July 17, 2007 @ 9:29 am

[...] For documentation on migration for PHP 4 to PHP 5, you could use the official PHP migration guide, or you could follow my tutorial on how to install PHP5 on Windows. [...]

06

AltaGid said,

August 20, 2007 @ 11:23 pm

Hello! Help solve the problem.
Very often try to enter the site, but says that the password is not correct.
Regrettably use of remembering. Give like to be?
Thank you!

07

Thomas said,

August 21, 2007 @ 8:42 am

If your comment is an attempt to drive visitors to your site you should focus on your spelling, especially since you appear to be offering translation services…

If you actually need help setting up a local server – please be more specific.

08

naisioxerloro said,

November 28, 2007 @ 4:34 pm

Hi.
Good design, who make it?

09

Thomas said,

November 28, 2007 @ 5:31 pm

I make… Check out the download section if you would like to try it on your own blog (if you have any)…

10

Almobbynemn said,

December 19, 2008 @ 8:49 am

Hi

As a fresh blog.evaria.com user i only wanted to say hello to everyone else who uses this site 8-)

11

Robor said,

September 10, 2009 @ 10:51 am

Hi there,
Everything dynamic and very positively! :)
Robor

URL for comments RSS 2.0 feed Subscribe to Comments | TrackBack URI

Leave a Comment

Akismet has protected Blogvaria from 108,696 spam comments. Design by Evaria.com. Powered by WordPress.
Our beloved and trusted server has rendered 3.038 pages so far today, an amazing 4.425 pages yesterday
and even more astonishingly 205.194 pages since 29 Jan 2010 alone without dropping a byte nor a pixel.

Close
E-mail It