XAMPP: Tips for Running an Apache/MySQL Server in Windows XP

Would you like to learn PHP programming? Would you also like to learn MySQL? If so, then do you have an Apache-MySQL powered website? If not, then all you need to do if you are using Windows XP is download and install XAMPP. Keep reading to learn more about this web server.

XAMPP is an Apache web server installed right in your Windows XP PC that will run offline and does not need an Internet connection. This is commonly called a “localhost” by many PHP web developers and in the open source community.

XAMPP is open source software; this means it is FREE. You do not need to spend a lot if you’d like to learn PHP programming and MySQL. All you need to do is have a personal computer (using Windows XP) and install XAMPP.

To give you a little background, 65% of websites are powered by Apache, so if you have the skills in Apache, PHP and MySQL web administration, then you have a lot of opportunities to make money in the online business world, both as a freelancer and an entrepreneur.

Terminology for Apache-based powered websites

Before you can use XAMPP, it is essential to learn important terminology in XAMPP and how it relates to the online world.

Apache is web server software. The purpose of this software is to provide control and administration of a website. Control and administration includes execution of scripts at the server side, and security checks or authentication. In a real web server, this is installed in a computer called “racks,” which is also run by either Linux or Windows Environment, but most configurations are powered by the Linux operating system, since it is the native OS of open source web server scripts, such as PHP.

Web server software like Apache is installed in a web hosting company’s computer. It interacts with your Internet browser (i.e. Firefox, Internet Explorer, Chrome, etc) as follows. First, your browser requests information from the web server. The Apache web server receives the HTTP request, and then executes PHP scripts to pull data from the MySQL database (if this is a dynamic website). Apache then executes scripts again to send the information back to you in HTML code, which is readable by your browser.

PHP is the programming language that is executed by the Apache web server on the server side, to process the user’s input and requests.

MySQL is the database; this is where all the website’s information is stored. For example, if your website uses a template which is stored in your web hosting space (website files ending in .php), then,  depending on the client’s request, PHP will pull the data from the database to fill in the website’s template, which is returned to your browser. The data could be anything, from products in an e-commerce website, MP3 files in a music website, posts in your WordPress blog or posts in a forum. Have you ever wondered why those pages are very similar? It is because the site is using a template, and those items presented are grabbed from the database using PHP scripts.

{mospagebreak title=Configuring XAMPP: Apache/PHP and MySQL in one package}

Without the need for hosting space, which is quite expensive for a beginner, XAMPP offers a free solution for using Apache, PHP and MySQL. All you need to do is download the XAMP package here:


If this link is broken, find it here: http://www.apachefriends.org/en/xampp-windows.html  

This tutorial uses XAMPP for Windows version 1.7.0. While versions may change in the future, the functionality will be the same.

Install XAMPP in the root of your hard drive. For example, if you want to install it in drive C, it should be located at C:XAMPP and not C:FolderXAMPP.

Detailed installation procedures are out of scope of this article, but I find the installation process pretty straightforward and easy. Just be sure to close all of the running programs during the installation process.

This one-time installation will install the three most important components in a web server (Apache, PHP and MySQL). The next thing to do is check whether XAMP is running properly after installation.

To do this, open your favorite browser and type in http://localhost. You should see the XAMPP control panel. If this successful, go to http://localhost/security/index.php to put in some security measures for the following items:

1. Ensure these XAMPP pages are no longer accessible by the network for everyone.

2. Give the MySQL admin user root password protection.

3. Ensure the PhpMyAdmin password login is enabled.

You can find out how to activate these security features here: http://localhost/security/xamppsecurity.php

Make sure it shows as “Secure” in the XAMPP security page: http://localhost/security/index.php. It is very important that if you are writing PHP scripts that communicate with the MySQL database, you write down this following information for the scripts to properly retrieve or insert data from the database:

a. MySQL username

b. MySQL password

c. Hostname

The MySQL username and password can be set in the above configuration; the hostname is “localhost.”

Bear in mind that since this is running in Windows XP, Apache and MySQL are started as part of the services which can be started, stopped or paused. You can access them by going into Control panel -> Administrative Tools -> Services.

Alternatively it can be accessed also in Start -> All programs -> Apache Friends -> XAMPP -> XAMPP Control Panel. Stopping and restarting Apache is useful if you have done something to the Apache server configurations, but at this stage you should not need to; it’s only necessary in case-by-case scenarios.

Stopping and restarting MySQL is useful in advanced resetting of MySQL passwords, which is difficult to do. This means you should keep a copy of your MySQL access details, and track it carefully.

Finally, this is a common mistake by beginners. Do not forget to access details to the following (after changing the security):

a. XAMPP — XAMPP will ask you for login details the next time you access the root http://localhost, so do not forget those things you have typed in above.

b. PhpMyAdmin — This is the control panel of MySQL, where you can easily create databases, tables, insert data, delete data and everything else, just as you need to do with spreadsheet data. If you set security settings, you will need the MySQL username and password to log into PhpMyAdmin

Finally, all configurations can be found here: http://localhost/xampp/ , as this is the control panel for XAMPP.

{mospagebreak title=Useful XAMPP Techniques}

After learning a bit about XAMPP, its security and features, we will proceed to illustrate some XAMPP techniques. Okay, let’s start with the basics:

Executing your first PHP script

Say that you have a script named “basic.php,” which is a PHP program. Executing the script in your local Apache server is made possible by saving your PHP/html source in the htdocs folder. If you have installed XAMPP in drive C, htdocs can be located in C:XAMPPhtdocs.

The files inside htdocs are the “local” or “offline” equivalent of the online web hosting root web server space. The root is the most important section of the web space because it is the reference for all folders. If you have website whose URL is http://www.yourwebsite.com/ , the forward slash “/” signifies the root directory. If you upload a file to the root directory via FTP, for example “thisisyourphpscript.php,” it can then be executed in your browser address bar as http://www.yourwebsite.com/thisisyourphpscript.php .

The offline equivalent of the above web address is this: http://localhost/thisisyourscript.php , provided you have saved the script in this Windows-based path: C:XAMPPhtdocsthisisyourphpscript.php

Creating a database and tables using PhpMyAdmin

This is why I love XAMPP; the PhpMyAdmin is bundled with PHP, and database creation is straightforward. To directly access the database, type this in the address bar: http://localhost/phpmyadmin and be prepared to input security details such as the username and password.

A tutorial on database creation and its details is beyond the scope of this article, but always bear in mind that database communication to PHP scripts is basically the same as what you would do when you upload your scripts online (of course you will need another MySQL username, password, hostname, etc.).

{mospagebreak title=Testing scripts in PHP 4 and PHP 5}

The good thing about XAMPP is that it is able to test the scripts you have written for compatibility in PHP 4 and 5. Here is the simple procedure:

1. Stop the Apache service by going into Control panel -> Administrative Tools -> Services -> Apache 2.2.

2. Go to All programs -> Apache Friends -> XAMPP -> PHP Switch.

2. An MS-DOS screen will then appear.

3. It will then show the current PHP version. If it is currently using PHP 4, you can switch to PHP 5 by typing 5, and then pressing enter. If the switch is successful it will give you the message "PHP Switching was successful." Then press any key to continue.

4. Finally, restart the service by going back into Control panel -> Administrative Tools -> Services -> Apache 2.2

5. To confirm the changes you can go to http://localhost/xampp/ and then click the phpinfo() link. It will then give you the PHP version that you have just switched on.

This completes our look at the basic tips for running an Apache MYSQL server in your Windows XP. In upcoming articles, I hope to cover some advanced techniques for using XAMPP, such as installing a CMS (content management system) in your local host, and configuring Apache directives such as httpd.conf and .htaccess and many others.

[gp-comments width="770" linklove="off" ]