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 2 3 4 5 6
  1. Weiss935 said Jun 11, 2008 at 10:52 pm

    IfModule> for mime_module
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    IfModule mime_module

    the doesnt work for me :S

  2. Weiss935 said Jun 11, 2008 at 10:51 pm

    ops i mean in 5.1 it is
    for mime_module
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

  3. Weiss935 said Jun 11, 2008 at 10:50 pm

    hi when i start apache it says:
    the requested operation has failed!

    i think it is something with step 5 and 5.1

    in 5 i have set:
    LoadModule php5_module “c:/php-5/php5apache2_2.dll”

    and in 5.1 i have set:
    for mime_module
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

    What is wrong?

  4. Werner Van Gelder said Jun 6, 2008 at 2:47 pm

    Good article, but copying the php dll files to your Windows system directory is a bad move.
    Add the php directory to your Windows PATH instead and everything works just fine. It will also be much easier to upgrade PHP in the future.

  5. Izzi said Apr 29, 2008 at 4:15 am

    i have apache2.2 and php5.2.5
    the RoSPORA V1.4.4 shows up in http://localhost/index.php but is essentially dead… but when I type my web servers dns name I get “It Works” in bold glorious letters! but no RoSPORA. I would like to know how to get RoSPORA to work upon typing my dns name instead of “It Works” (or if I type my dns name with /index.php and get a download to index.php…)

    Thx

  6. izone22 said Apr 24, 2008 at 5:46 am

    What do i tell my modem to open ports for? It is the httpd.exe? What ports are recommended?
    Thx everyone! :)

  7. Izone22 said Apr 23, 2008 at 9:07 pm

    What is PHP 5.2.x : 5.2.4 used for? Can you not just use Apache 2.2.x?

  8. James L said Apr 14, 2008 at 10:59 am

    When you said that we can edit the “localhost” information we put into apache at startup…how do we make it work for a url that we bought. I would like to know that Apache settings and the web site setting that i need to make.
    Thank You for the wonderful guid!!!
    James

  9. Kona said Mar 21, 2008 at 6:34 pm

    Hi!

    For Vista users, I Found out that in line

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

    Doesn’t work at least for me (Vista Business, apache 2.2.8.)

    To make it work i changed it to
    LoadModule php5_module c:\php-5\php5apache2_2.dll

    So no “-marks. I doesn’t seem to matter if you use backslashes or basic slashes (/ or \) pardon my english.:)

  10. vishal said Mar 19, 2008 at 2:10 pm

    Hello,
    You also go for Xampp or wamp. Easy to install and one click control panel for easy navigation.

    Very handy packeges.

    Thanks,
    Vishal
    vishalgaurav01@gmail.com
    http://vishal.benetonfilms.com

  11. DarkAssassinRO said Mar 14, 2008 at 5:06 pm

    and then add these lines inside that directive (before the closing for mime_module )

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

    cant understand this line :|:|:|

  12. DarkAssassinRO said Mar 14, 2008 at 3:41 pm

    When i tipe in cmd “net stop apache2.2 && net start apache2.2″ it says that itsuccesfuly stoped and when to start it says:”A service specific error occurred: 1. And i did all like in the:”Installing and Setting up Apache 2.2 series with PHP 5 on Windows”guide plss help me :(

  13. DonkeyKing said Mar 13, 2008 at 3:39 pm

    i agree with darkassassin
    the final step is to quick explaned
    a little guide would be handy

  14. darkassassin said Mar 12, 2008 at 7:34 pm

    Can anyone send step by step guide of how to make the website?plsss :((

  15. darkassassin said Mar 12, 2008 at 7:33 pm

    I’m a noob in this domain (servers0 but i made my wow server whit mangos i have navicat i have all made my server works i made a realmlist whitout hamachi,but i can’t understand how to make a website where all can create theyre accounts alone plss can someonehelp me?:(

  16. Alpha136000 said Mar 2, 2008 at 3:49 am

    please someone help me! i dont understand step 5.1 what do i copy and paste whats with the for mime_module
    and
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    Im so confused!

  17. taylor said Mar 1, 2008 at 6:49 am

    I was just wondering if some one can help me set up rospora because i have it all configured but its just a blank page and cant figure out how to get it working

  18. ShadyGhost said Feb 29, 2008 at 2:19 am

    Almost forgot,I use 2.2.2Apache and php 5.2.5.:)

  19. ShadyGhost said Feb 28, 2008 at 2:11 am

    Hi,Reaper.The guide is very good,Thx a lot for it.I have a problem,i asked a friend to connect to my server(Reaper Mangos 5225 2.3.3) I gived him my IP and DNS he sayed:”Got stuck on Connecting.”.I have a router,and a LAN but 3724 and 8085 are forwarded to me,how can I set my realm’s addres wich my friends to put in their realmlist.wtf file.And I am wondering how to get my Registarion page accesable I see it only in http://localhost/index.php,it is Rospa configured.
    Please answer me soon :)

  20. airtime373 said Feb 28, 2008 at 1:30 am

    ok so I can’t type the script, tht helps huh.. is there a way for me to show you what i typed?

  21. airtime373 said Feb 28, 2008 at 1:28 am

    ok I got everything up and running, but now i am having a problem. I wrote a test script, here it is

    the book I have said the output should look like this
    The size of Reno is 360000
    The size of Pasadena is 138000

    but I get

    The size of Reno is RenoThe size of Pasadena is

    what am I doing wrong? i am very much so newbie at all of this, and would really like to learn.
    Tahnks for the help

  22. DJeXeCute said Feb 27, 2008 at 6:11 pm

    airtime373 if you would like I could help you set it up via remote connect just add me on msn and give me a pm volkarcire@ath.com

  23. airtime373 said Feb 26, 2008 at 5:59 am

    Reaper-x can I install the latest version of php and apache using your tutorial?
    and once I get it done, I will need help installing phpmyadmin, I have tried 3 different times and keep getting the same errors, is there anywhere I can go and see something like what you did here, step by step help?

    There should be more people like you on here!!

  24. Vishal said Feb 25, 2008 at 2:13 am

    Hi,
    Lots of lots of website available for installing php and Apache.
    But this site is very different from other website.
    Anyone, if who have no technical background, he could able to install Apache and php on there machine by following this website instructions.

    I want must say thanks to reaper-x.

    Thanks,
    Vishal
    vishalgaurav01@gmail.com
    linuxvishal@yahoo.com
    http://vishal.benetonfilms.com

  25. Reaper-X said Feb 23, 2008 at 6:15 am

    #kc7wzl

    First of all i’m really sorry for late reply because i didn’t see your comment

    as for your question, the easiest way to do this since you have control over the httpd process is by editing httpd.conf manually

    here are the steps on how to prevent directory indexing by default even if there’s no index file exist

    1. Open httpd.conf

    2. Search for :

    LoadModule autoindex_module modules/mod_autoindex.so

    and replace it with

    #LoadModule autoindex_module modules/mod_autoindex.so

    3. restart the httpd service :)

    # denverbentley

    Configuring ROSpora actually easy ;) … all you have to do is just open the config file and replace the username value and database name with the database name you’re using for mangos and your done :)

    # sammy

    Your welcome sammy, glad this website can be useful for you :)

  26. sammy said Feb 22, 2008 at 8:31 am

    Thank you very much.
    I was unable to install and configure php untill i read this blog. This is great website.

  27. denverbentley said Feb 20, 2008 at 8:06 am

    Hi, I’ve set up everything perfectly thanks to your tutorials and such.. i was wondering one thing though. How can i see a log or something that would show me what new accounts have been made on my signup site(RoSpora).

  28. kc7wzl said Feb 18, 2008 at 9:11 pm

    I got it working first time around and also have PHPbb 3 working ( but at this time it is set to OEM setting and stuff ( other than a few changes to make things go ))

    what I would like to know is to stop apache from giving out dir info..

    what I mean is say if I have addy
    http://kc7wzl.servegame.com/somesubfoldername/
    and I dont have index.html in there it will list the contence in that folder..

    I would like to stop that from happening

    I have set it so if there is index.html , index.htm ,or index.php in the sub folder it will load those witch is good

    basicaly I want to make it if the addy was not correct IE somehthing like this

    http://kc7wzl.servergame.com/gooddir/badfilename.html

    it will give a error message not a listing of contence but if the user gives good addy like

    http://kc7wzl.servergame.com/gooddir/goodfilename.html

    it will give them the html requested.

    I know there has to be a way I just am too much of a dim wit to find it I guess

    kc7wzl

  29. Dexi said Feb 15, 2008 at 6:12 am

    Also in the final step (10) when Reaper tells ”to remove the ; from the extensions” what does that mean and where do i have to search for them and remove them?

  30. Dexi said Feb 15, 2008 at 6:07 am

    Guys i have installed both Apache – PHP and they work fine.
    I have forwarded the port but people can’t connect to the webpage and register. (i used the RoSpora one).
    The webpage is working fine by me as i can open it and make an account.

    Any help is appreciated,

    Dexi.

  31. Void said Feb 14, 2008 at 2:43 am

    You should add a tut for setting up a webpage. The RoSpora one is… well, confusing :\

  32. miqbal said Feb 13, 2008 at 9:48 pm

    One more thing, I do not use the MSI version for the PHP, only the ZIP version. And put it on “C:\php\…”. DO NOT put it on “C:\Program Files\php\…”

    thanks,
    iqb

  33. miqbal said Feb 13, 2008 at 9:41 pm

    Thanks, it works!!
    Mine: PHP 5.2.5, Apache Non-SSL 2.2.8
    advice: You should add the tut for MySQL:)

  34. Myselff said Feb 13, 2008 at 3:00 pm

    Never mind I found a link listed in the guide for a sample php.ini and httpd.conf. And everything seems to working, now to figure out how to have remote accont creations.

  35. Myselff said Feb 13, 2008 at 2:40 pm

    I am having the same troulbe as Void87.
    I have rechecked and rechecked and rechecked, everything in the guideut I keep getting the “A service specific error occurred: 1.
    More help is available by typing NET HELPMSG 3547″

    And now I cant get Apache to start.

  36. Void said Feb 12, 2008 at 5:20 am

    Hi again, I fixed the not starting problem, I forgot to add quotes in my config file. But even still, now when I type the address into the browser, it doesn’t display an error or 404 or anything, it just doesn’t show up (completely blank white page). I am using RoSpora, and I think I configured all the stuff right. My test.php shows up >_>

  37. Vishal said Feb 6, 2008 at 10:42 pm

    Hi,
    I see may times that, many new bies weites that, they get apache not starting message.

    Here is good solution for all new bies.
    Go for “wamp” – http://www.wampserver.com/en/.

    Wamp software include apache, mysql and php.
    very easy to install.

    if you are going to install all software your self.
    then follow this site steps.

    some users are not able to edit httpd.conf file.
    my suggestion is for all of them to, just download premade httpd.conf and php.ini file from this site. and paste it to your apache installtion directory.

    and some user made a mistake like.they are not able to see .php pages.

    very easy solution is

    first make sure that, your file is saved with .php extension.some of your text edittors are saved the file with filename.php.txt.
    but php engine cound not render text file as php.
    first make sure for thet.
    hope you able to run php.

    Thanks,
    Vishal
    vishalgaurav01@gmail.com
    http://vishal.benetonfilms.com

  38. Vishal said Feb 6, 2008 at 10:22 pm

    Hi,
    Always good idea is for new bie is, just download pre made httpd.conf file from this site and paste it to your apache installtion folder.

    I think, your problems would be solved.
    and ofcource, in this premade httpd.conf file have default php folder is “php-5″, make sure for that.

    Thanks,
    Vishal
    vishalgaurav01@gmail.com
    http://vishal.benetonfilms.com

  39. ARUELL said Feb 6, 2008 at 11:27 am

    Im getting there…(http://24.181.232.106/index.php) How can i turn this site into a site for my server to make account etc. I’m so close. Any links to a tutorial would be great thx. P.S Well done on the tutorial :)

  40. ARUELL said Feb 6, 2008 at 9:29 am

    Sorry for error and double Post..Its not UNICODE its UTF-8
    ____________________________________________

  41. ARUELL said Feb 6, 2008 at 9:25 am

    WHEN MAKING YOUR TEST.PHP IN NOTEPAD…MAKE SURE YOUR DROP THE BOX DOWN TO UNICODE…NOT ANSI! Problem Solved My friends…Only took a hour to figure that out

  42. Reaper-X said Feb 5, 2008 at 6:31 pm

    you can copy all .dll files that doesnt have php5apache* name on the root of php directory :)

  43. Kuro said Feb 2, 2008 at 6:29 am

    i restarted my computer and now i cant even connect back on my server myself!

  44. Kuro said Feb 1, 2008 at 11:00 am

  45. Kuro said Feb 1, 2008 at 10:59 am

    which folders do i put in my windows…folder
    im using 5.25 and 5.25 php has a lot more stuff, so its hard to follow the plan you gave

  46. alpha136000 said Feb 1, 2008 at 10:23 am

    can someone please simplify step 5.1 for me?

    i found so what do i do with it?

    and what is
    AddType application/x-httpd-php .php

    and

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

    for? what i do with em?

  47. Void87 said Jan 29, 2008 at 12:07 am

    Everything works except the last step, when I try to restart apache it gives me this message:

    “A service specific error occurred: 1.
    More help is available by typing NET HELPMSG 3547″

    And when I typed that it gave me this:

    “A service specific error occurred: ***.”

    Please help, I know some stuff about computers but not this >_>

  48. Jacob said Jan 27, 2008 at 3:44 pm

    How come it wont let me restart Apache with out this “#” in from of

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

    in the httpd.conf file

  49. Jacob said Jan 27, 2008 at 1:20 pm

    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\Divine Dragon>net start apache2.2
    The Apache2.2 service is starting.
    The Apache2.2 service could not be started.

    A service specific error occurred: 1.

    More help is available by typing NET HELPMSG 3547.

    C:\Documents and Settings\Divine Dragon>net helpmsg 3547

    A service specific error occurred: ***.

    EXPLANATION

    A service-specific error occurred.

    ACTION

    Refer to the Help or documentation for that service to determine the problem.

    C:\Documents and Settings\Divine Dragon>

    I keep getting this can someone help

  50. paged2 said Jan 27, 2008 at 2:39 am

    Hi,
    Not able to install mysql. can some one help me

Comments Navigation 1 2 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>