Configuring PHP on Windows 7 with Apache Web Server

12
2013-08
  • pnongrata

    I already have an Apache server (2.2.22) up and running on my local machine, and have been using it to serve back static content. I am now trying to install PHP (5.2+) so I can get Apache serving back dynamic content, and am running into a snag.

    I went directly to PHP's site and tried to download the Windows binary for 5.4.0. The installation instructions were confusing and wanted me to grab a WIX tool for some reason so I could then simulate an MSI installer (at the least thats what I gathered). So after about an hour of frustration, I abandoned that approach an instead went to SourceForge where I found this nifty MSI, which I know isnt a recommended/endorsed practice by the people at PHP for security/performance reasons, but I'm not running a Top 100 e-commerce site here...I'm just trying to get PHP up and running on my local machine for development purposes.

    When I ran that MSI, one of the first windows asks me which server I want to install PHP for. It listed the following options:

    • IIS/FastCGI
    • Other CGI
    • Do not install a web server

    I choose "Other CGI", under the premise that it was the correct choice for a WAMP stack setup (which is what I am aiming to achieve). After that, I just chose all the defaults/recommended settings and finished the installation. I now see PHP "installed" under C:\Program Files\PHP\.

    I expected that - after choosing "Other CGI" - it would have asked me to configure the PHP installation with my Apache instance (installed under C:\Program Files\Apache Software Foundation\Apache2.2\). But this was not the case, so my first question is:

    • Was I wrong to choose "Other CGI", and if so, how do I correct that mistake?

    Assuming I was correct to do this, then the only conclusion I can draw is that I must now manually go into PHP and configure/point it to work nicely with my Apache server. So my second question is:

    • If I do need to manually configure PHP, what is my next step here (can someone point me to the correct documentation, etc.)? And, if no manual configuration is necessary, then how do I get Apache serving back PHP pages?!?

    To test Apache/PHP, I made the following htdocs/test.php file:

    <? phpinfo(); ?>
    

    When I go to localhost/test.php it just gives me that same exact line of text (above), instead of displaying the normal/proper PHP Info page, which (obviously) indicates PHP is not working with Apache yet. Thanks in advance for any nudges in the right direction or helpful pointers!

  • Answers
  • bretterer

    I have always found that downloading and installing each thing on its own, it can be a bit of a pain. I have switched to using xampp Which provides me with everything you need to have a WAMP server (windows, apache, mysql, and php). XAMPP also provides you with filezilla and a mail server(though I have not been able to make the mail server work for myself). Not only do they support windows with their installer but they also do Linux and mac.


  • Related Question

    WAMP apache server : problem running php files
  • Bruce

    I have installed WAMP 2 and am using firefox 3.6. I have saved my php file test.php in C:\wamp\bin\apache\Apache2.2.11\htdocs and I now open http://localhost/test.php in my firefox browser but I get a file not found error

    Not Found
    
    The requested URL /test.php was not found on this server.
    

    What am I doing wrong?


  • Related Answers
  • 8088

    Place your files in the www directory. Right click on the WAMMP icon on the taskbar > Click on www directory to launch the directory and place your php files there.

    Also don't forget to start all services

    WAMMP

    Alternatively you can also use XAMPP. In XAMPP you have to place the files directly in XAMPP > htdocs folder.

    XAMPP also has a plugin for TOMCAT so that you can test java apps locally.