Apache/PHP on Windows 8

29,372

Solution 1

Download and follow instructions from this link: http://www.apachelounge.com/download/

The latest download (2.4) works on Windows 8 and Server 2012.

I downloaded and tested with the following on Windows 8: Each zip has a readme.txt or install.txt with instructions.

My httpd.conf lines that were added/modified were:

LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php5_module "C:/Apache24/php-5.4.8/php5apache2_4.dll"
LoadFile "C:/Apache24/php-5.4.8/php5ts.dll"
PHPIniDir "C:/Apache24/php-5.4.8"
<IfModule php5_module>
  <Location />
    AddType text/html .php
    AddHandler application/x-httpd-php .php
    #AddHandler application/x-httpd-php-source .phps
  </Location>
</IfModule>

Solution 2

Its mentioned in the Readme.txt file packed with the dll's at ApacheLounge, but not anywhere else on the download page or in the filename (as all other versions):

"Runs with PHP 5.4 Thread Safe (TS), and only with Apache 2.4 Win32 VC9 or VC10"

The dlls are only for the TS version, so if you've downloaded the other one, you are basically screwed. TS php binaries fixed it for me.

GL.

Share:
29,372
Simon Roberts
Author by

Simon Roberts

Updated on July 09, 2022

Comments

  • Simon Roberts
    Simon Roberts almost 2 years

    I'm having trouble with Apache/PHP on Windows 8. I have previously been using them on XP (along with MySQL) with no problems. I never used Windows 7.

    Apache installs without issues. Everything works OK, including all my virtual servers. PHP installs OK, the installation puts entries into httpd.conf without giving errors. However, when I try to load Apache after installing PHP, Apache won't load.

    I'm confused by the error that Apache returns when the PHP entries are included in httpd.conf:

    Syntax error on line 1029 of C:/Program Files/Apache Group/Apache2/conf/httpd.conf:
    Cannot load C:/Program Files/PHP/php5apache2_2.dll into server: The specified module could not be found. 
    

    The lines are:

    #BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
    PHPIniDir "C:\Program Files\PHP\"
    LoadModule php5_module "C:\Program Files\PHP\php5apache2_2.dll"
    #END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
    

    (line 1029 is the LoadModule line). That location for the dll is definitely correct. The syntax of the line is as inserted by PHP. I have compared the syntax to previous versions of httpd.conf that I have and it appears correct. I think the syntax error is a red herring.

    I have tried:

    • Switching backslashes to slashes in the dll location.
    • Adding PHP to the path.
    • Installing Apache and PHP in both sequences.
    • Checking the permissions to the PHP folder and the individual files to ensure that SYSTEM has read/execute.

    Comment out the PHP lines and Apache loads fine. If I comment out the LoadModule line and and just leave the PHPIniDir line, it still fails. Apache seems to be behaving as though it can't see the PHP directory, but I can't work out why.

    There is nothing on the Windows event log. Latest versions of PHP and Apache. I'm at a bit of a loss what to try next. Any suggestions please?

  • Havelock
    Havelock over 11 years
    That's more of a comment, not an answer really.
  • tonino.j
    tonino.j over 11 years
    No, it is a practical solution. No reason to pursue "purity" with windows.
  • Simon Roberts
    Simon Roberts over 11 years
    I've not used xampp before, but I'll give it a try. Thanks.
  • tonino.j
    tonino.j over 11 years
    If it solves your issue, don't forget to accept the answer
  • Jeffrey
    Jeffrey about 11 years
    I have no idea what the php5ts.dll file does, I guess something with threat safe, but it caused my local apache to become unlimited quicker when doing a request in IE, and about 300% quicker in FF. Thank you for providing your httpd.conf config!