Setting up XAMPP on Windows

With the growing popularity of Blogging and Content Management Systems the need to know how to utilize a stack or a package of applications that allow testing and building these type of dynamic driven sites locally before putting them live on a server has become essential to the modern designer/developer. I personally like to use XAMPP by APACHEFRIENDS. Which is really easy to setup. XAMPP stands for cross platform, apache, mysql, php and perl. It eliminates you from having to install and configure all of these separately. This stack allows you to actually setup on a USB drive which I thought was really cool, so I guess I have been a consistent user ever since discovering that.

This tutorial will guide you through getting XAMPP and setting it up, securing the directory and will eventually be followed up with some basics in getting around in PHPMyAdmin, using FileZilla server and experimenting with the Mercury Mail program.

Okay so lets get started, when were done with this tutorial you will be able to start building and testing that CMS you been dying to get into too.

xampp download page

Lets first download XAMPP from http://www.apachefriends.org/en/xampp.html.

Here is a screen-shot of where we will click the link for the Windows distribution. (as this tutorial covers setting up under windows.)

Then when we navigate to the following page we want to scroll down and look for the Download link. Look at this screen-shot below. Click on XAMPP. This will direct us to another page and we are going to choose to download the XAMPP Zip archive make sure you choose the full package not the upgrade. We are not going to choose the installer because we want to extract it ourselves. And nothing is added to the registry this way. So lets click on the ZIP link to begin downloading.

xampp download page

(Blurb taken from the Apachfriends site on installation) To install XAMPP you only need to download and extract XAMPP, that’s all. There are no changes to the Windows registry (not true if you use the Windows installer version of XAMPP) and it’s not necessary to edit any configuration files. It couldn’t be easier! To check that XAMPP is working some sample programs are included, there is a small CD collection program (written in PHP using MySQL) and a small guest book software (written in Perl) and several other demonstration utilities. If you decide that XAMPP isn’t needed any more just delete the XAMPP directory and it’s completely removed from your system. However if you use the Windows installer version of XAMPP it’s recommended to use the uninstall feature. As every installer the installer will make registry entries to remember the install.

So now we are directed to save the zip archive to our computer. Once finished downloading the archive use your favorite software to extract the zip archive. I use WinRar, available for download at http://www.rarlab.com/download.htm.

So now we want to extract the zip to where we want our XAMPP stack to be located. I will extract to a root directory. For example if you want to install it on your hard drive, extract it to C:\ or maybe Z:\ or even on a usb drive like E:\. (These drive letters may be different on your system obviously.) By leaving the path blank like Z:\ we will extract the XAMPP stack automatically to a folder that it creates itself called xampp. (See screen shot below.)

extract xampp

So when it’s finished extracting it should look something like this in windows explorer.( Z:\xampp ) (Screen-shot below) It is important that it’s extracted to a root level like this so don’t extract it into a folder like (Z:\SomeFolder\xampp) Otherwise you must run the “setup- xampp.bat” to set up the path configurations. Now you should be able to start XAMPP directly.

See screen-shot

xampp installation

Now we will run through the setup_xampp.bat. So go ahead and click on setup_xampp.bat. We will see a command prompt pop up and we follow the onscreen instructions. We can add shortcuts to the desktop which I never do.. :)

The main thing to realize here is if we want relative or absolute paths. If you are setting up to a USB Drive choose without drive letters. Because on each pc drive letters may change. (For instance your flash drive may be recognized as G:\ on your machine, but on another machine G:\ might be already taken by another device or drive.

I will choose without drive letters (relative path). As an absolute path would be with drive letters.

And last we can make sure the timezone is set correctly. Note: If your timezone is not correct see Setting or correcting timezones in XAMPP PHP MYSQL. Then once setup has been completed press x to exit the command prompt.

Okay now we are going to see if XAMPP has been configured correctly. So lets click on the apache_start.bat file inside the XAMPP directory. You should see a command prompt pop up. It will say starting apache, apache started press any key to continue. And do just that. See screen-shot below.

NOTE you may get a pop up from your firewall program that asks if you should block apache or allow it, obviously allow it. As well you may get this message for any other service you start.

apache start command prompt

Okay now lets also start mysql, so click on mysql_start.bat and now you will get another command prompt that says starting mysql, once mysql is started go ahead and hit any key to continue. Now we could also start FileZilla Server (filezilla_start.bat) and Mercury Mail Server (mercury_start.bat) but we will not in this tutorial, however I will discuss using them in a later tutorial.

Okay now we want to open up a browser and type in http://localhost or http://127.0.0.1 . Now we should see the XAMPP splash screen in our browser and select your language probably English then you should see this page. (see screen-shot below)

xampp success page

Okay now if you saw the XAMPP welcome page then your XAMPP is running and setup. Now we are going to look at the status page just to make sure things are working. We also could look at the info pages or the demos that are built to see if things are working correctly. But we wont walk through that here we are more concerned with the status.

Lets click on status. We will be navigated to a page that displays whats active or not. We should see that MySql database, PHP, Perl with mod_perl, Apache:ASP, HTTPS(SSL), CGI, SSI, and IPv4 are activated. IPv6 may be active or not. Now some of these might be different on your system. SMTP and FTP are gonna be deactivated because we never started them, unless you did. (filazilla_start.bat, mercury_start.bat)

(see screen-shot below)

xampp status

Alright well I’m sure that everything is looking good on your system because XAMPP is really that easy to install.

Okay now we are gonna do one last thing and that is secure up our MySQL Root User, MYPHPADMIN and XAMPP Directory. Go ahead and navigate to the security page this will show you a status on security. Your machine will most likely read XAMPP -unsecure, MySql – unsecure, MyPHPAdmin – unsecure and Ftp, Pop3, and Tomcat are probably unknown. So lets secure the Directory and give the root account a password. Go ahead and click on the http://localhost/security/xamppsecurity.php link. We will then be brought to the security page where we can enter our own credentials to secure up XAMPP. (see screen-shot below)

xampp security

Now create a password for the MySQL SuperUser “root” and leave the radio buttons to default authentication “cookie” and set random password for the myphpadmin pma user “yes”. Check the box also to save the passwords in a text file.(I would write this info down too.) Then click on password changing.

Now what we just did was set a password for the user “root” which has all privileges. You can use this user to login to myphpadmin to create databases and such.

Now we need to secure the XAMPP directory. So type in a user name and a password and check the box to save it in a text file.(I would write this info down too.) Now click the secure XAMPP Directory button.

Now you will be redirected to page that shows where your setting have been saved. Good, now go turn off the services in your XAMPP installation. Find in explorer where you extracted the zip. (Z:/xampp) And click on mysql_stop.bat, and then click on apache_stop.bat. As you click on each one you will get the command prompt, wait until it verifies that the service has been stopped for each and hit any button to continue. Now once you stopped them, start them back up again. First start apache_start.bat then mysql_start.bat.

Okay good now we will go back to our browser and enter http://localhost in the address bar. If you setup the security right and restarted your services, you will be prompted to enter your user name and password you created for the XAMPP directory. Enter those in. (see screen shot below)

xampp user

Okay now once your in the XAMPP welcome page go click on security to see the security status. It now should read that XAMPP pages is secure, MySql admin user has a password – secure, and phpmyadmin password login is enabled – secure. Okay now our XAMPP stack is setup and secured. (see screen shot below)

xampp security

Now to begin using XAMPP you need to just find the folder htdocs. This folder is found in your XAMPP installation, (Z:\xampp\htdocs)This folder will house all of your web applications. You may want to create a new folder inside of this htdocs folder for each application or website that you want to use with XAMPP for testing and building. Inside the htdocs folder you basically will see another folder called xampp. What your looking at is the files that are used when your navigating your local host directory like the XAMPP splash page, status, security and etc. You don’t want to delete this folder or the two index files php and html. So to stay organized and keep your work seperate from the XAMPP interface, create a new folder for each project you embark on.

So to view your work you would use a path like http://localhost/mynewfolder . Now lets test it, (1) Create a new folder named test inside your htdocs folder. (z:/xampp/htdocs/test) (2) Open notepad and type in some basic html, with maybe just a paragraph tag with the word “test” in it. (3) Save it as index.html and inside your folder you created called “test”. (4) Now type http://localhost/test/index.html in your browser address bar and you should see your test page in the browser.

Okay so now we have got XAMPP setup and running on our machine, now we can begin testing and building dynamic content locally. Like that Joomla! Content Management System you been wanting to explore or that WordPress site you want to setup locally and test before going live.

Good luck and I hope this tutorial helped you setup XAMPP on your windows machine. I will post more tutorials that are related to this topic, (I will link here when they are up): such as some myphpadmin basics like setting up a database, importing/exporting. Using FileZilla and Mercury Mail for testing locally. Working with WordPress and Joomla! locally.

Posted in Web Developer | Tagged , , , | Leave a comment

Setting or correcting Timezones in XAMPP PHP MYSQL

When setting up XAMPP using the setup_xampp.bat file, sometimes it may not get the timezone right. So in order to fix this we need to adjust two files the php.ini and my.ini. First lets locate the php.ini to change the setting there. Open up your installation of XAMPP and browse to here (root dir)(c:\ or where you setup xampp) xampp\php\php.ini and right click on the file and choose open with notepad. Do a edit/find search for “timezone” this will bring you to an area that looks like this:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = “America/New_York”

Okay before your do anything back this file up. Now go open up a browser window and go here to find your correct timezone, http://us2.php.net/manual/en/timezones.php once you find your correct timezone for example America/Los_Angeles copy and paste into where the old timezone was like this:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = “America/Los_Angeles”

Now save the php.ini file and you will have to restart apache for any changes to take effect but we must also change another file first. So lets navigate to (root dir) :\xampp\mysql\bin\my.ini open the my.ini file in notepad, do an edit/find search for “time-zone” this will bring us to an area like this:

default-time-zone = “America/New_York”

Now backup the my.ini file and change the line to this:

default-time-zone = “America/Los_Angeles”

Okay now save the file, the timezones have been corrected go ahead and restart your apache and mysql to activate the changes made.

Posted in Web Developer | Tagged , , | Leave a comment