Saturday, October 5, 2024

Setting up Apache, PHP and MySQL on Windows

I’m writing this article assuming you’re running Windows XP on your computer. Even if you are not, you can use this article to setup these three on almost all basic Windows flavors.

INSTALLING APACHE

First of all you need to install Apache. You can get a binary installation file from http://apache.roweboat.net/httpd/binaries/win32/apache_2.0.48-win32-x86-no_ssl.msi

Once you have downloaded the installation file, run it. During the installation process, it asks you for the following:

The Installation Path

Chose a partition drive (if you have different drives on the same computer), let us say, C:.

Network Domain

If you are installing (which I guess is the case for the time being) Apache for learning purpose, it doesn’t really matter what you type here. Just enter yourname.com.

Server Name

Enter www.yourname.com

Administrator’s Email Address

Enter you@yourname.com.

For Whom To Install Apache

Select “For All Users”. You need to run Apache as a service in order to make it show your pages. If you select the other option, you may have to start the service whenever you have to use Apache for development and learning purposes.

The Installation Type

Select “Custom” and then let it install all the things mentioned in the list.

That’s it. If no catastrophe has occurred yet, Apache should be installed on your computer. Assuming you chose the c drive, the path of the program should be: c:Program FilesApache GroupApache2.

INSTALLING PHP

You can download the latest version of PHP (for Apache on Windows) from http://in.php.net/get/php-5.0.0b4-Win32.zip/from/a/mirror

After you have downloaded the file, extract it in a suitable folder. Let the path be c:php.

You can run PHP for Windows in two ways: – a CGI executable (php.exe) and as an API module. I recommend using the API module and we’ll configure PHP that way.

Once you have installed PHP in c:php, locate a file there named php.ini. Copy this file to WINDOWS or WINNT folder.

If it is not already set, set extension_dir=c:php in your php.ini file.

Now the part where PHP runs as an API module.

You need to locate two files in c:php and they are php5apache.dll and php5ts.dll. Make sure these files here in this folder and in the same location.

Remember you installed Apache in c:Program FilesApache GroupApache2? In Apache2 there is a folder “conf” and in this there is a file “httpd.conf”. Open this file (I suggest you take a backup of this file before tinkering with it), and add the following lines somewhere:

LoadModule php5_module c:/php/php5apache2.dll AddType application/x-httpd-php .php

If you want to use a PHP file (index.php) go to the line that contains:

DirectoryIndex index.html index.html.var index.shtml

Add index.php to it such that it appears as

DirectoryIndex index.html index.html.var index.shtml index.php

That’s it. You are ready to unleash PHP on your computer.

INSTALLING MYSQL

Finally we come to installing MySQL. Now that as soon as you begin programming in PHP you’ll start creating database applications, but now that we are installing Apache and PHP, it’s better to install MySQL too and be done with it.

Download the appropriate zipped file from http://www.mysql.com/downloads/ and unzip it into some folder other that mysql (better keep this folder reserved for the actual MySQL program). After unzipping it, run the setup file and install the whole thing is c:mysql. MySQL is installed. It needs to run as a MySQL server in order to make it work with your PHP program.

In c:mysqlbin there is a file namely “winmysqladmin.exe”. Whenever you want to use MySQL, first run this program.

Another program that comes in handy while handling MySQL is MySQL-Front that you can download from http://www.mysqlfront.de/. We’ll come back to this tool once we start studying about MySQL.

Amrit Hallan is a freelance copywriter,
and a website content writer. He also dabbles
with PHP and HTML. For more tips and tricks in
PHP, JavaScripting, XML, CSS designing and
HTML, visit his blog at
http://www.aboutwebdesigning.com

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles