Reaper-X » How To » PHP » Tutorials » Windows » Installing and Setting up Apache 2.2 series with PHP 5 on Windows

Installing and Setting up Apache 2.2 series with PHP 5 on Windows

Previously i wrote a how to guide on installing Apache HTTPD 1.3 on Windows machine. But it seems that some people prefer to use the new Apache 2.2 series instead of the old httpd 1.3 series which is not good when used on production system (read: if you allow anyone to access your webserver), beside the apache website itself tell you this :

the older 1.3 series was never designed to run on Windows, but that support was ‘hacked in’, introducing a large number of potential thread saftey issues and other confirmed problems.

And that’s why i choose to create the apache guide again but this time it is using the 2.2 series, and of course this guide tell you on how to setup your apache server with php 5 manually not using an all in one package. And here’s the guide :

Requirements :

1. Apache 2.2.x : At the time i wrote this guide, the latest stable version is 2.2.26 (btw get the non-ssl version unless you plan on using ssl)

2. PHP 5.2.x : 5.2.4 is the latest stable version when i wrote this (get the zip version, not the installer)

And here are the steps :

Note : in this example i’m using the default installation path for Apache 2.2

1. Install Apache 2.2 until below screen appears and use this information (or adjust it to your liking) and then continue the process until finished :)

Apache Installation Process

2. To make sure Apache is working now you need to open your browser window and type http://localhost as the address, and if you get the same message like below image that mean apache is working

Apache Default Page

3. Thanks God the Apache seems to work … but now you’ll need to configure apache so it’ll recognize the php files and can parse the php files correctly. And the first thing you should do is extracting the PHP zip archive somewhere, and in this example i extracted the php 5.2.4 files into C:\PHP-5

4. After finished with the extraction process, now you just need to go to your Apache installation path, and then open httpd.conf which is located under the conf directory using your favorite text editor. Btw if you installed apache using the default path, here’s what the apache directory structure looks like

Apache 2.2 Path

5. In order for apache to parse the php files correctly, first you need to Load the PHP5 module into the Apache, and to do this you just need to add below line to your Apache httpd.conf (after the last line of the loadmodule section) :

LoadModule php5_module “c:/php-5/php5apache2_2.dll”

Note : Adjust the php path accordingly if you extracted it into other directory

And here’s the image :

Php loadmodule apache 2.2

5.1 Now you need to search for (use your text editor built-in search function) :

<IfModule mime_module>

and then add these lines inside that directive (before the closing </IfModule> for mime_module )

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

6. After finished with the above process, now you’ll need to configure apache so it’ll check the existence of index.php by default too instead of just checking the index.html only for the default index filename, and here’s how to do it

The default configuration from Apache 2.2 :

<IfModule dir_module>
DirectoryIndex index.html
</IfModule>

The modified version :

<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>

Notice the difference ? i’m pretty sure you’ll notice it right away … but like everyone knew that a picture worth a thousand words (read: because my English language is bad), so here goes the picture

Apache directory index

7. Now we are done with the httpd section, now we need to configure php. Here are how to do that :

7.1 Copy php.ini-recommended from your php5 directory into C:\Windows (or your windows path) and then rename it into php.ini

7.2 Open the php.ini file using notepad and change the extension_dir as shown on below image :

Php extension dir

7.3 Now you need to copy some dlls from your php 5 directory into C:\Windows\System32 :

Php dlls

Im pretty sure that you can’t read the filename from the above image, but don’t worry because all you have to do is just :

Right click and choose Arrange Icons by name, and then copy each file shown on the above image into your windows system32 directory, and you’re done (hint: hold CTRL key to select multiple files)

Or … copy all dll files at the root of your php directory into your system32 directory except those that is using php5*.dll

8. Now we’ve configured php, apache … but what else do we need ? of course we need to make sure that php really working and apache can parse it without problem, so we need to create a php test page first, here’s how to do it :

8.1 Create a file named test.php inside C:\Program Files\Apache Software Foundation\Apache2.2\htdocs (because that’s where the default document root path of your apache)

8.2 Add below line to the test.php file like shown on below image, then save and close the notepad

Create php test file

9. Okay … finally we’ve reached the final stage !!! now you just need to open command prompt and type like below image :

Apache 2.2 restart

If you can’t read what you should type from the above image, actually you just need to type :

net stop apache2.2 && net start apache2.2

to restart your apache 2.2 process

10. Now after finished restarting the apache process, we need to open the browser window and point to http://localhost/test.php

Php test page

If you see something shown like on the above image, that means Apache and PHP is working on your system

Congrats … now you’ve got apache and php 5 working on your system the only thing left is … adding mysql support (if you plan on using a registration page for your Mangos Server or other private server), and to do this you just need to remove the ; from the extensions, for more information, you can download the sample php.ini and httpd.conf as a supplement for this short how to guide

Hint : Compare the sample php.ini file you’ve downloaded with the default php.ini file from the php.ini files included in PHP archive (in this case you can find it on your windows directory)

Hopefully i didn’t miss anything, but if you do notice that i miss something, please let me know so i can fix it or add it :)

Thanks to Al for the suggestion :)

Tags: Apacheapache 2.2GuidehackhttpdmangosmediafiremysqlPHPphp 5php5private serverserverSoftwarewebserverWindowswow

Leave a Comment

Comments Navigation 1 ... 3 4 5
  1. Fredy said Sep 21, 2009 at 9:03 pm

    Can u please add these files, the sample php.ini and httpd.conf here for adding mysql support.

  2. Fredy said Sep 21, 2009 at 9:00 pm

    “Congrats … now you’ve got apache and php 5 working on your system the only thing left is … adding mysql support (if you plan on using a registration
    page for your Mangos Server or other private server), and to do this you just need to remove the ; from the extensions, for more information, you can download the sample php.ini and httpd.conf as a supplement for this short how to guide”

    I am trying to add mysql support and i tried to download this sample php.in but i can not get it. i can not even open what i dowloaded. Can u please help!! Thank you for your guide

  3. Mohan said Sep 3, 2009 at 1:55 pm

    Excellent instructions, the screen shots and tips helped configure php plugin for apache.

  4. Sagar said Aug 28, 2009 at 9:44 pm

    grt dude.. many thnx!!!!!

  5. Guang said Aug 14, 2009 at 2:05 am

    This how-to rocks!!! It works.
    (Except for the picture of the dll file, but the text instruction below that works.)

  6. Lord Belial said Jun 7, 2009 at 11:17 pm

    What a great help you have given to me!! I was having problems with installation because of the apache`s version. I was using the guide of David Powers “PHP for Dreamweaver 8″, but he uses apache 2.0 version, not 2.2. Thanks a lot and keep going, English, believe or not, is a window to the world :D. Greetings from Mexico, yea! :p

  7. dreamluverzd said May 18, 2009 at 9:19 pm

  8. LoDer said May 7, 2009 at 4:04 am

    Thank’s!
    It’s easy even for 5-year girl)

  9. melissa said Apr 7, 2009 at 9:53 pm

    Gosh thanks this is the most noob-friendly tut! Godbless!

  10. Mari said Mar 14, 2009 at 12:57 am

    Thanks very much for the useful article.

  11. greetingsfrompoland said Mar 7, 2009 at 11:48 am

    Hello to all ! Greetings From Poland. very Good Page !

  12. Nexus2322 said Jan 21, 2009 at 3:09 am

    so ive been getting an error while installin apache..

    Installing the Apache2.2 service
    The Apache2.2 service is successfully installed.
    Testing httpd.conf….
    Errors reported here must be corrected before the service can be started.
    (OS 10048)Only one usage of each socket address (protocol/network address/port)
    is normally permitted. : make_sock: could not bind to address 0.0.0.0:80
    no listening sockets available, shutting down
    Unable to open logs
    Note the errors or messages above, and press the key to exit. 15…
    this happens before it even gets to finished..

    any ideas on what im doing wrong? id like to get this php server working

    ugh

  13. fahim said Dec 30, 2008 at 10:08 pm

    GOT IT!!!

    whoever has a problem with a 404 error of not finding the test.php fine from the htdocs folder.

    Save your test.php file WITH QUOTES like “test.php”

    Worked for me!!!

    Thanks Reaper-X for your excelled guide..

  14. fahim said Dec 30, 2008 at 9:45 pm

    btw…. it does locate the “index.html” file…

    can you guide me in any way plz?

  15. fahim said Dec 30, 2008 at 8:56 pm

    I did everything following your guide, (except that you location “php-5″ I used “php” since in my C i have it as php…thought it was worth mentioning)

    everything starts properly, it just doesn’t find the “test.php” file that I created in htdocs.

    Any help here plz?

  16. br4ink1ller said Dec 29, 2008 at 11:50 pm

  17. br4ink1ller said Dec 29, 2008 at 11:26 pm

    nice it works for me….
    apache_2.2.10-win32-x86-no_ssl.msi and php-5.2.8-Win32.zip

  18. Brian D. said Nov 14, 2008 at 7:07 am

    I’ve got everything setup, however I have 2 questions/issues.
    1. http://www.mydomain.com works, but mydomain.com displays the “It Works!” page. How do I fix so both work?
    2. I cannot get mod_rewrite to work. I have enabled the module in the httpd.conf file, but it is still not working. What are all the steps in getting this functional?

    Thanks for the help, these are great instructions.

  19. hotwaxham said Oct 2, 2008 at 8:03 am

    Reaper-X ,

    Everything works well following your instructions using apache_2.2.9-win32-x86-no_ssl-r2.msi & php-5.2.6-Win32.zip . Thanks so much!

    I’m just having a problem understanding how to implement RoSpora.Build.V1.5.0.Rv.01.rar .

    I downloaded it but it has no instruction on how to make it work. Can you give me a direction on what I have to do with RoSpora to get their sample to work. Here is their website: http://worldofwarcraft.powerlogy.net/

  20. Shai'tan said Sep 18, 2008 at 3:24 am

  21. amaterasu said Sep 14, 2008 at 12:32 am

    Congrats! And lots of thanks…you saved my nervs!

  22. AdmSpock said Aug 10, 2008 at 4:35 am

    I just upgraded from apache 1.3 on windows (yes, I know, should have done ages ago…) and for some reason the database modules were not working…

    After reading this article I know why:

    Turns out some dll files need to be copied to the system32 dir….

    Thanks!

  23. Roy said Jul 24, 2008 at 5:55 pm

    Thank you very much, Ive just upgraded my skills and local server to php 5.2.2.6 & apache 2.2 from php5.0 and apache 2.0 in minutes….

  24. Chili said Jul 16, 2008 at 11:42 am

    Thanks for awesome guide’s.
    I have made my server work fully and the minimanager is working on my current PC, but now id like to go public.
    Can my minimanager site be on different IP/host than my game server is ?
    and if so , in where can i put my gaming server details on ?

    Cheers ^^

  25. Gosszilla said Jul 15, 2008 at 10:06 am

    I must be doing something wrong in editing apache, when it doesn’t come up, the port is successfully opened, when apache is up, the port times out.

  26. Gosszilla said Jul 15, 2008 at 9:58 am

    ok I can still see the site, the port checker says the port has timed out, and I have put the port into the windows firewall as an exception

  27. Gosszilla said Jul 15, 2008 at 9:45 am

    oops i forgot to restart apache, but now it doesn’t work, which numbers am I supposed to change to not mess up my apache?

  28. Gosszilla said Jul 15, 2008 at 9:41 am

    Ok I have changed everything that says 80 in httpd.conf to 3977 and had my router forward that, but it says the connection is refused, the wow ports are successful but this one is really bothering me. Please help

  29. Gosszilla said Jul 15, 2008 at 9:23 am

    Oh, appearently port 80 is not allowed to open on my router, how do I change which port apache uses?

  30. Gosszilla said Jul 15, 2008 at 9:13 am

    Oh, this is strange I followed everything from the tutorials perfectly, except not too sure about step 5.1, but anyway I have the php part installed and I can see the site, but my friends can’t connect to my site or my server, I have these ports open, except for port 80 which I can’t seem to find what is using it… Task Manager doesn’t show the PID under processes, is there some special way? BTW the other ports are opened and supposedly connectible.

  31. Leon said Jul 11, 2008 at 7:11 pm

    Appreciate the article.

    Thanks!

  32. Weiss935 said Jun 12, 2008 at 3:32 pm

    Do you think you can upload a new index or something? because when i registry an account it just comes blank and i don’t have an account.

  33. Weiss935 said Jun 12, 2008 at 3:22 pm

  34. Reaper-X said Jun 12, 2008 at 2:49 pm

    background? do you mean set up background for your website or ..?

  35. Weiss935 said Jun 12, 2008 at 3:43 am

    what do i need to write a background?

  36. Weiss935 said Jun 12, 2008 at 12:50 am

    i’ve got it working now :D

Comments Navigation 1 ... 3 4 5

Trackbacks/Pingbacks

CommentLeave a response

Please read our comment policy | XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>