Installing php:-
  • Download the zip archive of php from this site.
  • Extract the archive to a c:\php or any name that you like but in the entire explanation c:\php is assumed to be the path where php is installed so replace it with the path to your directory in case you choose to install it in another directory .
  • Rename the php-ini-dist to php.ini because it is the configuration file for php.
  • This completes the basic install and now you can change the configuration parameters in the php.ini like the timezone, displaying errors etc.
Configuring apache web server(almost all people use it):-
  • Then you will have to configure apache web server and that's the tricky part because there are compatibility issues between the apache web server version and the php installation.
  • If you have the php version 5.2.10 then you can configure it for apache web server 2.0.x but the php version 5.3.0 comes with support only for the apache web server 2.2 or greater so you should check the version of apache that you have before downloading php or vice versa.
  • Configuring Apache 2.0.x :-

    • If you have apache 2.0.x then you should download php version lower than 5.30 as it only supports the apache web server 2.2.x
    • Open the apache configuration file httpd.conf and search for "LoadModule" and after the last LoadModule directives just copy and past the following code.

      #php5 module for apache 2.0.x web server LoadModule php5_module "c:/php/php5apache2.dll" #Tell apache web server to recognize the .php extension AddType application/x-httpd-php .php #The php.ini directory assuming it to be the same as c:/php PHPIniDir "c:/php" #end of php5 module

    • Note that we are loading php as a module into the apache web server but you can also load it as a cgi binary. Also note that the dll that was loaded is php5apache2.dll which supports apache 2.0 web server.
  • Configuring Apache 2.2.x :-
    • The steps remain the same but in this case you have the option to download the php 5.3.0 version but lower versions of php also support the apache 2.2.x web server because they contain the php5apache2_2.dll required for the apache 2.2.x server.
    • Just copy and paste the following code at the end of LoadModule directives in the httpd.conf file and i am assuming the installation directory of php is c:\php.

      #php5 module for apache 2.2.x web server LoadModule php5_module "c:/php/php5apache2_2.dll" #Tell apache web server to recognize the .php extension AddType application/x-httpd-php .php #The php.ini directory assuming it to be the same as c:/php PHPIniDir "c:/php" #end of php5 module



    • In this case note that only change is in the LoadModule directive which loads the php5apache2_2.dll which is loaded by the apache 2.2.x web server.

  • Save the http.conf file, restart the apache web server and create a simple test script and place it in the apache htdocs directory. In the test script type and save it as test.php in the apache htdocs directory. Open the browser and type http://localhost/test.php, the installation if successful will show the page containing details about php installation and apache web server.


Activating mysql support for php:-
  • Open the installation directory of php i.e c:\php and then open the php.ini file and search for ;extension=php_mysqli.dll and remove the semicolon in front of it if you have mysql version 4.1 or greater because the mysqli(improved) dll file is for mysql version 4.1 or greater but if you have an older version (although it is highly unlikely) then remove the semicolon from the line that says ;extension=php_mysql.dll .
  • Open the ext directory under the directory where php is installed and if your mysql version is 4.1 or newer then copy and paste the php_mysqli.dll file from it to the main directory i.e directly under the c:\php directory or else copy and paste the file php_mysql.dll.
  • Note that there should also be a libmysql.dll file directly under the main directory,if not then copy and paste that file from the directory similar to the "C:\Program Files\MySQL\MySQL Server 5.0\bin" directory.
  • Now you have to set the path variable by appending c:\php directory path into it so that php can find the 2 above mentioned dlls required for mysql support. To see how to set the path variable see this link.
  • Reboot the pc and start the apache webserver, open browser and type the url to the file we created earlier i.e http://localhost/test.php and if everything goes fine you should see the output similar to the image shown below. This completes the installation of mysql support for php.