Setup your own apache sever with php and mysql, the easiest way using XAMPP

5 July 2009 | 6 Comments » | Mujtaba

Many php developers find it difficult to test and debug their php scripts on their web host’s server, as it consumes much needed time, but what if you had your own PC turned into an apche server with the latest version of php and mySql? Manual installation of apache and php and their configuration to meet your needs is not an easy task, but with Apache Friends XAMPP , the task becomes as simple as installing a software or extracting a zip archive! XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl. XAMPP is really very easy to install and to use – just download, extract and start. .

XAMPP (current version 1.7.1 ) includes :

  1. Apache HTTPD 2.2.11
  2. MySQL 5.1.33
  3. PHP 5.2.9
  4. Openssl 0.9.8i
  5. phpMyAdmin 3.1.3.1
  6. Webalizer 2.01-10
  7. FileZilla FTP Server 0.9.31
  8. SQLite 2.8.15
  9. Zend Optimizer 3.3.0
  10. Mercury Mail Transport System v4.62

How to install?

XAMPP currently comes in 3 variations :

Installer : as simple as installing a software

ZIP Archive: just extract and use

Self-extracting ZIP archive

The choice is yours, i downloaded Self-extracting ZIP archive as it is very small in size and convenient to install.

Using the Self-extracting ZIP archive, extract all the contents to a top level directory in your hard drive, eg: C:/xampp

Now to manage your Apache and mySql services, open the XAMPP control Panel located at xampp/xampp-control.exe . Click on “start” button next to Apache to start your server, now open your browser and go to http://localhost/ , you should now see the XAMPP splash screen , that means your server is now working fine and you are all ready to run your php code on your PC. To run your php scripts, place all your files in xampp/htdocs directory and then call http://localhost/yourscript.php where yourscript.php is the name of your file.

Default passwords

The default user for mysql is root and password is “” , that means no password

So connect to the databse using php you can use mysql_connect("localhost","root","");

you can also change your mySql username and password here is how

Installing Wordpress using XAMPP

You can even set up a fully functional “local” wordpress blog on your PC, you can use it to test and debug your wordpress themes and plugins in live. To get started, download wordpress and place the wordpress directory in xampp/htdocs

folder, now go to http://localhost/wordpress/ where wordpress is your wordpress blog directory and follow onscreen instructions

But before going further, you will have to manually create a database in mySql for your wordpress blog, to create a new database go to http://localhost/phpmyadmin/ and create a new database with thw name of your choice,
now back to wordpress installation, enter the name of the database you just created in the database field, for usename enter “root” and leave the password field blank and submit. If everything goes fine, you will now be prompted for a title for you blog. Hooray!
your local wordpress blog is now ready, copy the password generated and login to the admin area, happy “local” blogging :) .

Installing XAMPP on your USB stick

Now this is the best part of XAMPP, you can even install XAMPP right on your USB drive! It can come really useful in situations like when you have to demonstrate to your client a site that uses php and mySql
on his PC. to install XAMPP on your USB drive, simply extract XAMPP to your USB stick instead of your hard drive and enjoy!