Certify Urself
  Site Stats

Setting up WAMP

 

In this entry, I'll share some of my experience to help you setup your PHP scripting environment. I'll keep adding more articles related to this whenever I have the time, but for now let's start off by getting things to work.

 

We'll be coding PHP on a W.A.M.P setup. In case you haven't heard of WAMP, it simply means a combination of Windows, Apache web server, MySQL database, and PHP scripting (or Perl / Python).

 

Let's start off by downloading the required...

 

The Apache Web Server is available at http://www.apache.org/

MySQL Database can be found at http://dev.mysql.com/downloads/

and PHP can be found at http://www.php.net/

 

Installing the required software should be fairly simple therefore I shall not describe in detail. Our next step would be to configure our web server.

 

Configuration of Apache Web Server

  1. Locate your Apache installation folder, and expand til you see the file \Apache2.2\conf\httpd.conf
  2. Open up the file using Notepad or your favourite text editor.
  3. Paste the following code at the end of the file:

  4. LoadModule php5_module "c:/php/php5apache2_2.dll"
    AddType application/x-httpd-php .php

    # configure the path to php.ini
    PHPIniDir "C:/php"


  5. You should replace all instances of "C:/php" with your PHP installation folder.
  6. If you want apache to automatically lookup a file when the filename is not specified at the URL, simply paste the following in your httpd.conf file:

    DirectoryIndex index.html index.php main.php
    #Now if you browse to http://www.yourwebsite.com/
    #Apache will search for the 3 default documents
    #in that order, instead of showing the directory index

  7. Your Apache configuration should be almost complete for now.

Configuration of PHP

You should make a copy of the "php.ini-recommended" file that came with PHP, and rename it to just "php.ini". Be sure to deposit the file at the location you specified earlier in your apache configuration file (i.e. C:\PHP)

Next, open up php.ini in notepad, hit Ctrl-F and search for "extension_dir", this parameter specifies the directory where your PHP extension modules are stored. For me, its "c:/php/ext/", therefore it should look like

;Directory in which the loadable extensions (modules) reside.
extension_dir="c:/php/ext/"

Next locate the section where you see

;extension=php_mysql.dll
;extension=php_mysqli.dll

These are the libraries we're going to require later for MySQL connections. Remove the semi-colons in front of both lines to uncomment them so that they will be activated.

MySQL

There isn't much to configure for MySQL for the moment. You may leave most of the default settings. You'll be asked to enter an administrator password towards the end.

You might want to consider downloading the MySQL GUI Tools also found at http://dev.mysql.com/downloads/

 

Ready to begin

Create a file named index.php and drop it into the htdocs folder found at your Apache installation folder. Enter the following as the contents of the file:

<?php

phpinfo();

?>

Save your file and browse to http://localhost/ using your browser. phpinfo() shows information about the current state of PHP.

Being able to see those information on your browser also means that you have everything setup correctly and you're on your way to more PHP programming!

 

 


 

 

Link Referral