How To Install PHP with Apache (Part 2)



Configure PHP

  • After download, create a directory named php5 in your C: drive, then extract all its contents to “C:\php5″. It will look like this

  • Now locate php.ini-production in C:\PHP5 then rename it to php.ini

  • Now open php.ini and locate extension_dir directives, uncomment and change the value into
"C:\PHP5\ext"

  • Next you need to find output_buffering, in same php.ini file, and change it to
output_buffering = Off


  • Now locate php_bz2.dll, php_mbstring.dll, php_mysql.dll, and php_mysqli.dll and uncomment them.

  • We are done with the php.ini configuration,

  • Now we have to configure the Apache, for this open the apache configuration folder at location C:\Program Files\Apache Software Foundation\Apache2.2\conf which is by default.

  • Open the file Httpd.conf, from that folder and make following modifications to it.

  • Un-comment expires_module, headers_module, rewrite_module and then add
LoadModule php5_module "c:/php5/php5apache2_2.dll"


  • Add: (with other AddType block)
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps


  • Locate

DirectoryIndex index.html
DirectoryIndex index.html index.htm index.php


  • Now Save and close that httpd.conf file.

  • Now we need to set enviroment variables. For that….

  • Click on Start> Right click My computer Icon> Select Properties> On pop-up window, go to Advaced Tab> Click on environment variables

  • Locate Path under System Variables and then double click on it then add
;C:\PHP5

  •  Further in Environment Variables, next you need to click New Button and then add
Variable name: PHPRC
Variable value: C:\PHP5

  • Click OK>OK to save the settings.

  •  Now we’re done, let’s begin the test, if all this works or not.

  •  Go to C:\Program Files\Apache Software Foundation\Apache2.2\htdocs create a new text file inside that directory named test.php (NOTE: Do check the extension, .txt won’t work) and open it with notepad then add this
<?php phpinfo(); ?>

  • Now save all your work and restart your machine.

  • After reboot, open up your Browser, and type following in the address:
http://localhost/test.php

  • If the following page appears, congratulations!!!

          

0 comments:

Post a Comment