Wednesday, January 20, 2010

Install Apache HTTP Server + PHP5 on Windows 7 (64bit)

Recent installation of dokuwiki (a simple web-based wiki engine) requires a combination of Apache HTTP Server + PHP5 on my 64-bit Windows 7 machine, but setup process didn’t seem to be as simple as “following the wizards”. So I decide to jot a few lines down such that I don’t have to search on the web again when I need to repeat the installation.

1. Install Apache HTTP Server; (just go to the official site and pick up .msi, and install in default path C:\Program Files(x86)\Apache Software Foundation\ seems to be ok)
2. Install PHP5;

This worth a short paragraph. My understanding of the install steps on PHP website is that it should be automatically taken care of by the installation wizards if it is for a popular http server like apache, and the install wizard UI does indicate that too. But unfortunately I didn’t get it to work in which I either got an general error message or no error message but just not working. So I switch to the zip version of PHP5 which is suggested by some article online and following the steps below makes it work properly:
2.1 Unzip the the zip version of PHP5 to your local disk; (unzip it to C:\Program Files(x86)\PHP5 seems to be working too)
2.2 Open httpd.conf file of Apache HTTP server in a text editor;
2.3 At the end of the http.conf file add following lines to make Apache HTTP Server be aware of PHP5; (adjust you path accordingly)
1: # Begin enable php5
2: LoadModule php5_module "C:/Program Files (x86)/PHP5/php5apache2_2.dll"
3: AddType application/x-httpd-php .php
4: PHPIniDir "C:/Program Files (x86)/PHP5"
5: # End enable php5
2.4 Save the change and restart Apache HTTP Server, and if successful you should see
“Apache/2.2.14(Win32) PHP/5.3.1” in the status bar of Apache Service Monitor.
Now your Apache HTTP Server should be able to display php content, at least my php based dokuwiki is running perfect.

12 comments:

  1. Done as you suggested but equals a fail.

    ReplyDelete
  2. Many thanks!

    The installer didn't work. The ZIP version is the good option for PHP5.

    ReplyDelete
  3. Many thanks. This worked perfectly with one small change:
    you have to download the PHP5-zip in the VC6-Version (for Apache Server) and NOT as linked VC9 (that would be for IIS).
    Apart from that, all is perfect :D

    ReplyDelete
  4. try placing
    phpinidir "c:/program files (x86)/php5"

    before loading modules

    ReplyDelete
  5. I've tried all the tips above but no joy. I've tried using the msi and the .zip, VC9, VC6, non/thread safe versions of each, different machines entirely, but still can't get Apache to come up with PHP. Without PHP Apache starts fine, but I need PHP for my applications. Any further suggestions?

    ReplyDelete
    Replies
    1. Refer to this, it maybe help you:
      http://www.bundsoft.net/show_page.jsp?type=misc&id=525002

      Delete
  6. thanks
    works excellent

    ReplyDelete
  7. Yingxi

    is there a special Apache which should be installed in Win 7 64 bit, and is there a site where one can get instructions on how to install Apache like that

    ReplyDelete
  8. please send your reply about the win 7 64 bit apache install to

    axisnexus@gmail.com

    thanks in advance
    Michael

    ReplyDelete
  9. Yingqi Tang, thank YOU VERY MUCH!! it finally WORKS!!!!

    ReplyDelete