Apache 2 with PHP 5
[indent]This guide is for any user that is running Windows (any version) and wants to run the Apache Web Server with php5.[/indent]

  1. Download Required Files

    • Apache
      [indent]Go to Apache Download Section and download Apache. I'm using Apache version 2.2.8 for this tutorial.[/indent]

    • PHP Files
      [indent]Go to PHP.net and download the Windows zip package 5.2.x (or whatever the current release is). Do NOT download the executable files.[/indent]

  2. Install Apache

    • Run the Apache Install program [Image]

    • Input "localhost" for the network domain, "localhost" for the servername, and "root@localhost", or any email address you want, for the administrator's email address. Also keep the default selection of running apache for all users on port 80. [Image]

    • Choose a "Custom Install" option [Image]

    • Customize the settings as you feel fit. Most of them can be left as default though.

    • Install the Apache Webserver on your system

    • Make sure Apache is Running. You should see the feather logo in the system tray if you are running the ApacheMonitor program (which is the default) [Image]

  3. Set Up PHP

    • Unzip the PHP files to a directory [Image]

    • Rename php.ini-recommended to php.ini

    • Edit php.ini file as needed
      [indent]Run through the php.ini file and change any items you want. I use the error level E_ALL & E_STRICT in php5. You can change them to what you want. I also load a bunch of modules. There is no "master" setting, so fiddle with it until you get what you need / want.

      	[b][color=red]NOTE:[/color][/b] You should set a default timezone in your php.ini file.  For a listing of default timezones, please refer to the PHP manual's [url=http://us.php.net/manual/en/timezones.php]Timezones Page[/url][/indent]
      	[*] Copy php5 folder to its permanent spot [[url=http://phpbuilder.bpatterson.net/WAMP_Install/php_1.png]Image[/url]]
      	[indent]You can put this anywhere you please.  Most people tend to put it at the root of C: "C:\php".  You can put it wherever you like.  Since PHP is a program, I'm going to stick it in "C:\Program Files (x86)".
      
      	[b][color=red]NOTE:[/color][/b] I have an x86_64 system so I have both C:\Program Files and C:\Program Files (x86).  There is no special difference between the directories in this case.[/indent]
      [/list]
    • Create httpd-php.conf file

      • Create a new file in <Apache Root>/conf/extra/ called "httpd-php.conf"

      • Inside the new file, put either block for running PHP as a CGI or running it as a Module:

        # PHP 5 as CGI
        <Directory "[color=red]C:/your/path/to/php5/[/color]">
        	Options +ExecCGI
        	Order allow,deny
        	Allow from all
        </Directory>
        ScriptAlias /php5/ "[color=red]C:/Program Files (x86)/Web Server/php5/[/color]"
        AddHandler application/x-httpd-php5 .php5
        Action application/x-httpd-php5 "/php5/php-cgi.exe"
        
        
        #
        # PHP 5 as Module
        LoadModule php5_module "[color=red]C:/Program Files (x86)/Web Server/php5/php5apache2_2.dll[/color]"
        
        <IfModule php5_module>
        	AddType application/x-httpd-php .php .php3 .php5
        	AddType application/x-httpd-php-source .phps
        	PHPIniDir "[color=red]C:/Program Files (x86)/Web Server/php5[/color]"
        </IfModule>
        		
      • Edit the spots in red to reflect the proper path to php5
        [indent]NOTE: If you're running Apache 2.0.x, then use php5_apache2.dll. If you're running Apache 2.2.x, then use php5_apache2_2.dll[/indent]

      • Save the file

      • Edit httpd.conf and add this line (includes previously created file):

        Include conf/extra/httpd-php.conf
    • Add PHP to path of Windows

      • Right click on "My Computer" and select "Properties" [Image]

      • Vista Users:
        [indent]Click on the link in the left that says "Advanced System Settings" [Image][/indent]

      • Open the "Advanced" tab in the System Properties box

      • Click on the button which says "Environment Variables..." in the lower right hand corner [Image]

      • Edit the "Path" variable in the "System Variables" section [Image]
        [indent]You need to add the paths to your PHP folder separated by a semi-colon ";". For example, my addition looked like:
        ;C:\Program Files (x86)\Web Server\php5[/indent]

    • Restart the Computer
      [indent]It's best to restart the computer because windows needs to update it's Path variable since we edited it. It's optional, but until you do, some extensions may not load properly.[/indent]

    That's it. By this time you should have a working copy of php5 on your system for testing. To test this, you can simply create a new document called info.php and in it put the following contents:

    <?php phpinfo(); ?>

    Now save this file to the DocumentRoot which you defined in your httpd.conf file above (by default it's "<Apache Root>/htdocs") and then browse to http://localhost/info.php and you should see a slew of information about PHP and your system spit out at you [Image]

    [ NOTE ] I removed the part about php4 concurrency because php4 is reaching EOL (End of Life) and as such, you should not be running it. You should be running php5 from now on. If you still need help running php4 concurrently, feel free to ask me; however, I won't support php4 past it's life.

    a month later

    Hi bpat1434,

    I'm going to install Windows Vista Home Premium 64 on my computer.

    But, I'm affraid that program like Apache and PHP will not work correctly.

    In the other reply for 'installing php on vista 64', you wrote "...and Vista Ultimate 64 is my OS...".

    Does it mean that this tutorial also compatible for all Windows Vista 64 edition?

      Yes. Apache and PHP will run on any Vista release.

        Thanks bpat, thats great!

        Did you also write tutorial for installing mysql and ssl for Apache 2.2?

        I'd like to read them as well.

          bpat1434 :: Tutorial Above wrote:

          Go to Apache Download Section and download Apache. I'm using Apache version 2.2.4 for this tutorial.

            6 months later

            Can you install PHP under windows without installing any server application? I mean only to verify your code and check if its working?

            Thanks?
            TW

              Can you install PHP under windows without installing any server application? I mean only to verify your code and check if its working?

              Thanks?
              TW

                Can you install PHP under windows without installing any server application? I mean only to verify your code and check if its working?

                Yes, but then you would be using the command line interface, and that may not be what you want for verifying web application code to check if it is working.

                  With the CLI you can check for syntax errors. But just because there are no syntax errors doesn't mean the code will run as expected 😉

                    11 days later

                    You might want to make a note for the newest version of apache (2.2.8) you will need to reference "php5apache2_2.dll" instead of "php5apache2.dll". Apache will not start if it is referencing the old apache dll.

                      That's not entirely correct. The apahce 2.2.x line needs php5apache2_2.dll while the 2.0.x line will use the php5apache2.dll file. It's been this way since 2.2.0 😉

                      And I plan on revamping this soon. Probably this weekend sometime.

                        15 days later

                        Updated the above steps with new images (finally I put them back up). Ran through them again myself and everything seems good.

                          a month later
                          5 months later

                          i am using xampp.....i am not anle to run phpscripts...my php version is 4....it is saying something like "something wrong with installation"...can anyone help//please?

                            XAMPP is a software package, you'd have to ask support from them about installation. THis thread was for installing Apache, PHP, MySQL. Each being separate items, not installing through XAMPP or any other meta package like that.

                              i am using xampp.....i am not anle to run phpscripts...my php version is 4....it is saying something like "something wrong with installation"...when i referred the net,it says that some path has to be changed in .conf in apache to php..i cant follow that...can anyone elaborate on that?

                                Once again, ask on XAMPP's forums. This thread deals with installing the individual parts of the "AMP" installation (Apache, MySQL, PHP). We don't offer support for specific packages. I don't use XAMPP or WAMP.

                                If you want support for xampp, please go here

                                  4 days later

                                  Updated steps to fix a flub on my part. Added note about php5_apache2 vs php5_apache2_2 DLLs.

                                    2 months later

                                    ok never mind I got this one... still working on upgrades though.

                                      4 months later