Showing results for 
Search instead for 
Did you mean: 

Servers: Installing Apache, MySQL and PHP


Servers: Installing Apache, MySQL and PHP

Tutorials & FAQs: Servers: Installing Apache, MySQL and PHP

In this tutorial I'll demonstrate how to create a fantastic PHP & MySQL testing and development environment using the industry standard web server Apache. Everything you require for this can be downloaded from the Internet for free and is easy to setup. The guide is aimed at Windows 2000/XP users, however if you use Windows 9x, the proceedure is similar - see the 'readme' files included with each download for specific changes.


Firstly, let's start with MySQL. This is a completely standalone application, so it can be installed first. Head over to and download the Windows version with installer. Unzip this somewhere on your desktop and run Setup.exe. Follow the wizard; the default install location is C:\mysql.

Finish the wizard and fire up Notepad. You need to specify where you installed MySQL - edit the example that can be found where you unzipped, e.g. at C:\MySQL\my-example.cnf. Save this in your root directory (for example CSmiley as mycnf.cnf

If you get stuck, there is a lot of helpful information in the 'Documentation' Section of the MySQL website, at

The C:\MySQL\bin folder contains all the files for MySQL to run. Open up Command Prompt and enter

C:\mysql\bin\mysqld-nt --install 

to run MySQL as a service.

Go to Start>Programs>Administrative Tools>Services. Find MySQL on the list and click start. You can test to see if MySQL is working by entering

C:\mysql\bin\mysql test 

in Command Prompt.

Now you need to change the Root username and password for access. You need to enter MySQL in Command Prompt - use this as a guide:

C:> C:\mysql\bin\mysql mysql

mysql> DELETE FROM user WHERE Host='localhost' AND User='';
mysql> QUIT
C:> C:\mysql\bin\mysql\admin reload
C:> C:\mysql\bin\mysql\admin -u USERNAME password PASSWORD


Now MySQL server is running, we need to install Apache. Go to You need to download the Win32 version with the MSI installer. There are two releases of Apache to download - version 1.3.xx or 2.0.xx. Both are adequate for our use, but version 2.0.xx is the most recent and has several improvements over 1.3.xx. However at the time of writing, PHP support for Apache 2.0.xx is only experimental.

You can install Apache wherever you want - I'll use C:\Apache. In the "Server Information" box, you need to type localdomain in the Network Domain box, then either localhost or your IP address (if you want to allow external access to your server) in the Server Name box. Tick the All Users box.

Finishing this wizard will setup Apache shortcuts on your Start Menu. From here you can Start/Stop/Restart Apache, access the logs and change its settings. Settings for Apache are held in a file called httpd.conf. You'll need to edit this to install PHP.


We currently have both MySQL and Apache running - next job is to install PHP. Go to - make sure you download the Win32 ZIP file (this has support for MySQL and Apache, the other doesn't). Extract the ZIP file to a sensible location, e.g. CTongueHP .

Open the location you unzipped to, and find a file called php.ini-dist . Open it, then find the extension_dir setting and change it to where you unzipped, e.g. C:\PHP. Now save this in your Windows directory as php.ini. Note: this is also a file called php.ini-recommended. This could also be used, but is suggested for production servers.

Now you need to tell Apache what to do with PHP files. Click on the option in the Apache group on your Start Menu to "Edit the Apache httpd.conf configuration file". Scroll down to about 2/3rds of the file to find a section called AddType. Depending on what version of Apache you are running, add the following code (edit location if necessary). This code may change, especially with Apache 2.0, so double check your PHP readme file!

Version 1.3.xx

LoadModule php4_module c:/php/sapi/php4apache.dll

AddModule mod_php4.c
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Version 2.0.xx

LoadModule php4_module "c:/php/sapi/php4apache2.dll"

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Now, save httpd.conf and exit. Click Restart in the Control section of the Apache group on your Start Menu. Now, your system is ready for testing.

In Apache, all the files that will appear on the server are kept in the "htdocs" directory, if you installed in the default location it would be C:\Apache\htdocs. Fire up notepad and type:

<? phpinfo(); ?> 

Save this as info.php in your htdocs directory.

Now open an internet browser and type in http://localhost/info.php . You should get a page of information about PHP. Note, when you access Apache from your machine, you type in localhost, regardless of if you've set an IP as the Servername.

Test MySQL

Open Notepad again and type in:


<head> <title>MySQL Test</title> </head>
<?php $connection=mysql_connect("localhost","USERNAME","PASSWORD")
or die("Could not connect to MySQL");
echo "Successfully connected to MySQL";

Replace the username and password with those you created when MySQL was installed. Then save it in your htdocs directory as mysqltest.php. Now go to http://localhost/mysqltest.php and see what happens!


The last part is to install phpMyAdmin so you can manage MySQL databases and tables easily. Go to and download the Zip file of the latest stable version.

Now unzip this to a folder in your htdocs directory, for example C:\Apachehtdocs\PHPMA . Find the file and open it up in Notepad.

You need to find and edit the following lines:

$cfg['PmaAbsoluteUri'] = 'http://localhost/PHPMA/';

This sets the absolute address of phpMyAdmin. Change it depending on what folder in the htdocs you unzipped to.

$cfg['blowfish_secret'] = 'PASSWORD';

Enter a password to use for keeping phpMyAdmin secure.

$cfg['Servers'][$i]['host'] = 'localhost';

Set this to localhost if not already set.

$cfg['Servers'][$i]['auth_type'] = 'cookie';

This determines how phpMyAdmin authorises your login. Cookie is recommended.

$cfg['Servers'][$i]['user'] = 'USERNAME';

Enter your MySQL username.

Now save this file. You shouldn't change any of the other options unless you feel confident in doing so! Open up your web browser and go to http://localhost/PHPMA or wherever you installed to. Login with your MySQL Username and the blowfish password you just created.

Other Servers

A popular alternative to Apache as your webserver is Abyss. This is free and available for Windows, MacOS X, Linux, and FreeBSD operating systems. It is also very easy to install ASP, PHP or Perl onto it using the guides available on their website at

A good listing of free server tools can be found at

Tutorial written by James Hancock and originally published on

Installing Apache, Mysql and PHP

Wondered if you had a tutorial aimed at Linux users as well?

Im running Linux Suse 9. and I would like to install Mysql PHP and apache, correctly. I know these technologies come with my Linux distribution but any advise on how to set them up would be helpful.
I am trying to install the latest versions, so I've downloaded them from their respective websites.

I have managed to install Mysql already but I cannot seem to change the ownership of mysqld (daemon) which currently is running as the root user.

Thanks in advance

Servers: Installing Apache, MySQL and PHP

HMM, we where going to post some links to the many good tutorials available ont he net. For the most part, the best ones are on the websites of the repected creators.

As for running MySQL as non-root, well.

MySQL runs on port 3306. This is a non-root port (ie, above port 1024) and as such, any user should be able to start the MySQL deamon, provided they have filesystem access to the respected parts of the filesystem that will store the data.

Servers: Installing Apache, MySQL and PHP

hi, jus asking will this work for setting up counter strike stats. Because the php page i uploaded to my server isnt support i understand (i think) doing the above will make it support it..or sumthing along those lines.

Heres where i got lost:

Click on the option in the Apache group on your Start Menu to "Edit the Apache httpd.conf configuration file".

Apache group? = total confusion
On my start menu...which start menu? the big green one with START on it?
if so..i dont see any pache group on it, mainly because i dont know what an apche group is.

Servers: Installing Apache, MySQL and PHP

nice tut but needs updating. It aint that simple with the new versions of php, mysql and phpmyadmin.

Servers: Installing Apache, MySQL and PHP


Are you refering to the recent upgrades by PN to the CGI server?