How To Install Your Own Web Server – Installing PHP

June 4th, 2008

PHP On Windows TutorialIn the third part of this tutorial, we’re now going to install PHP 5 on Windows.

In the two previous posts, we’ve seen how to install Apache and MySQL on a Windows computer so you you should already have a working web server and database server.

How To Install PHP5 On MS Windows

  1. Head over to http://www.php.net and download the latest version of PHP from the “Downloads” section. From the Windows Binaries, get the zip package, not the installer. The latest version at the time of this writing is PHP 5.2.6.PHP5 Windows Tutorial
  2. Extract the content from the archive into C:\PHP (or wherever you want to install PHP but at the root of your hard drive the preferred location).PHP5 Windows XP Tutorial
  3. Using Notepad (or any non-formating text editor) open Apache’s configuration file (c:\Apache2\conf\httpd.conf)
  4. Find the section where modules are loaded and insert the following lines:
    LoadModule php5_module "c:/php/php5apache2.dll"
    AddType application/x-httpd-php .php
    PHPIniDir "C:/php"
  5. Now find the DirectoryIndex parameter and index.php so it looks something like this:
    DirectoryIndex index.php index.html index.html.var
  6. Save and close the httpd.conf file.
  7. Copy c:\php\libmysql.dll and c:\php\libmcrypt.dll to c:\windows\system32
  8. Using Windows Explorer, find the file named php.ini-recommended in C:\PHP and rename it to php.ini (ie.: c:\php\php.ini).
  9. Open php.ini with Notepad.
  10. Uncomment the line that begins by “include_path” under the Windows comment.
    ; Windows: "\path1;\path2"
    include_path = ".;c:\php\includes"
  11. Find the extension_dir parameter and set it to:
    extension_dir = "c:/php"
  12. Find the mysqli extension parameter and uncomment it:
    extension=php_mysqli.dll
  13. Do the same thing for extension=php_mbstring.dll and extension=php_mcrypt.dll
  14. Right-click on My Computer and select Manage. Restart the Apache2 service as shown below.Windows PHP Tutorial
  15. Using Notepad, create a new file and insert the following content:
    <?php phpinfo(); ?>
  16. Save this file to c:\Apache2\htdocs\phpinfo.php
  17. Open your web browser at http://127.0.0.1/phpinfo.php
  18. If everything went correctly, you should see the PHP information page:

You now have a functional web server with PHP and MySQL support running on your Windows computer!

But it’s not over yet. We still need to do a few things:

  • Create a MySQL database and a database account
  • Create a virtual host
  • Install phpMyAdmin so you can manage your database content and structure

Stay tuned, I’ll be posting the final part of tutorial soon.

Click here to subscribe in a RSS reader or to receive email updates.

12 responses so far ↓

1. Response by : How To Install Your Own Web Server - Adding A Virtual Host on Jun 10, 2008 at 5:13 am

[...] Restart the Apache2 service (Don’t remember how? See step #14 from this post). [...]

avatar

2. Response by : PK on May 25, 2009 at 1:20 pm

I am a student following your tutorial and I am having some trouble.
I am installing PHP 5.2.9 on Windows XP.

I was able to get the phpinfo.php in my web browser.
When I went back to look at it again -
I get a black page in the web browser.

Any suggestions?
Thanks
PK

avatar

3. Response by : The Web Hosting Hero on May 25, 2009 at 1:23 pm

Are you sure IIS is running?

avatar

4. Response by : PK on May 25, 2009 at 2:02 pm

No – I am very green when it comes to this. How do I check?

Thanks again for your help?

avatar

5. Response by : PK on May 25, 2009 at 2:09 pm

I just checked my control panel and IIS is not an added component on my machine. I will keep troubleshooting.

avatar

6. Response by : The Web Hosting Hero on May 25, 2009 at 9:22 pm

Sorry I meant Apache, not IIS.

avatar

7. Response by : Paul Goldman on Jun 10, 2009 at 1:48 pm

Outstanding series of tutorials. I got an Apache/MySql/PHP test environment up and running on an XP workstation with almost no trouble. The one glitch I hit was due to the fact I had installed Apache 2.2 but initially used the php5apache2.dll rather than the php5apache2_2.dll. Figured it out quickly when Apache wouldn’t restart.

Thanks again,
Paul

avatar

8. Response by : kannan on Jan 24, 2010 at 1:15 am

how to install php and mysql in my client server…

avatar

9. Response by : Andy on Jan 28, 2010 at 7:24 am

Great tutorial. I had to change the slashes in the path name at step 4 from “/” to “\” to get my server restarted. Hope this helps anyone.

avatar

10. Response by : Matt on Feb 18, 2010 at 3:35 pm

How do I get Apache2? Like in step #14.

avatar

11. Response by : The Web Hosting Hero on Feb 19, 2010 at 3:50 pm

@Matt: did you install Apache first?

avatar

12. Response by : Eugene on Mar 24, 2010 at 7:45 pm

followed the instructions, but phpinfo is not loading properly, just loads the code as text. any suggestions?

Leave a Comment




Webmaster Resources: Web Hosting Blog
© Copyright 2012 - TheWebHostingHero.com
Follow us on TwitterFacebookSubscribe to our RSS Feed