XAMPP Tutorials, Among Other Things

Wednesday, December 21, 2005

Installing XAMPP on Mac OS X

Introduction: This tutorial will be the base tutorial for future projects that will run off of XAMPP. It will cover basic installation and security practices, and will be detailed enough that a semi-competent computer user should be able to follow it without much trouble. For those computer-savvy users out there, please take note that this tutorial was written so that just about anyone can understand it. I'm sorry if it is a little slow moving, but I know how much it sucks when there is an awesome tutorial out there but it was written so that you have to be a genius to understand it. Also, remember this: Everything presented in this tutorial is potentially damaging if done incorrectly. I cannot be held responsible for any damaged caused as a result of this or any other tutorial, whether directly, indirectly, or other *irectly scenario. In other words, it doesn't matter if your computer swallows your cat, its still not my fault. Sorry!

Mac OS 10.4 Tiger
XAMPP for Mac OS X
High Speed Internet
Static IP Address
A relatively fast computer (1GHz or Faster G4 or G5, 512mb of RAM)
Administrative Privileges
Anywhere from 15 minutes to an hour, depending on your knowledge of how Macs work

Please note: If you have any web or MySQL server running on your computer, it is required that they be disabled before installing XAMPP. But hey, if you already have either of these things, then why do you need XAMPP?

Step 1: Download XAMPP to your desktop.
If you can't figure this part out, stop here. Come back when you learn to use a computer.

Step 2: Install XAMPP
This step should be relatively self explanatory. Double click on the installer package and follow the step-by-step instructions on installing the software.

Step 3: Starting Xampp
Here comes the fun stuff. Open up Terminal (Applications/Utilities/Terminal). It would be useful to put Terminal in your dock, as you are going to be using it quite a bit. You should see a screen that looks something like this:

Type the following commands in Terminal:

cd /applications/xampp/xamppfiles/

sudo ./mampp start

After entering those commands, you should see something like this:

The command "cd /applications/xampp/xamppfiles/" means "Change the current working directory to /applications/xampp/xamppfiles." In other words, it tells the program Terminal to go to your applications folder, then go to your xampp folder, and finally go to your xamppfiles folder. The command "sudo ./mampp start" is a little more complicated. the first part, "sudo," tells the computer "I want to perform the following command with administrative privileges." That is why you need to enter your password to run this command. The next part, "./mampp start," tells the computer "Run the command mampp, which is in the current directory, and tell it to start." For more information on what these commands do, do a google search for "UNIX tutorials." At some time, I will post a UNIX tutorial on this site. For now, you'll just have to trust me.

Caution: Always use the sudo command with care. If you aren't quite sure what you are doing, then it is my recommendation that you don't do it. The sudo command can do some pretty awesome things, but it can also be incredibly destructive.

Step 4: Test XAMPP
Now you get to see if your (not so hard) work paid off. In your web browser of choice, type in either "localhost" or "" (each without quotes.) You should see a screen that looks like this:

Congratulations! You now have a working installation of XAMPP on your Mac. If you don't see something that looks like this, review the steps mentioned above and try again. Click English, and you will see the XAMPP administrative screen:

Click on "Status" on the navigation bar, and you will see a list of different XAMPP components. If everything worked as it should have, each component should show "ACTIVATED" to its right. After checking this, head over to the security page. Most likely, you will see something like this:

You guessed it–thats not a good thing. You want your website to be secure! Open up Terminal again. If you haven't closed the Terminal window since you last used it, you should be able to enter the command

sudo ./mampp security

If you get an error that looks like this:

-bash: ./mampp: No such file or directory

then enter these commands:

cd /applications/xampp/xamppfiles

sudo ./mampp security

You should now see a prompt asking if you want to set a password to protect your XAMPP pages; type yes or press return and enter a password at the prompt. (Note: For the security conscious, it is recommended that the passwords that protect your computer as a server differ from your administrative account's password.) Next, it will ask you if you want to turn off MySQL access from over your network. For now, type in yes and hit return. It will restart MySQL, and then ask if you wish to set MySQL root password. Type in yes, hit return, and enter a password at the prompt. Finally, it will ask you if you would like to enter a password for the FTP account. type in yes, hit return, and enter a password at the prompt. Go back to your internet browser and hit refresh on the XAMPP security page; if everything was done right, your browser should ask you for a username and password. For the username, type in "xampp." For the password, type in whatever you were using to secure the xampp pages. You're installation of XAMPP is not (relatively) secure.

Note: Although these instructions cover securing your XAMPP installation, it is impossible to guarantee security without knowledge of the system XAMPP is being installed on. You have been warned.

Step 5: Adding Web Pages
Okay, so you have this nice web server installed on your computer all ready to use. The only problem is, you want to put your website online. Not the XAMPP admin page. Well, heres how you do it. Open the folder called htdocs (located at /Applications/xampp/htdocs). You will see a file called index.html. That is the default web page, just waiting to be replaced with something more interesting. However, there is one problem; you don't have the correct permissions to edit this file (or place any other files in there, for that matter.) Actually, you can, as an administrator, drag any files you want to and from that folder, you just have to click "Authenticate" every time you want to do so:

This is fine. The only problem with this is it is difficult to edit files saved in this directory. You can fix this in one of two ways; you can edit the file in emacs using the root account, and you can simply copy the file you want to edit, edit it, and move it back to the htdocs directory, clicking yes when it asks you if you wish to replace the file with the same name. The second method is pretty self explanatory; the first one would require an article of its own, so I won't put that in here.

step 6: Opening Your Server to the Outside World
If your computer is connected directly to your cable or DSL modem, you can skip this step. However, if you are connected through a router, you will need to configure port forwarding in order to allow the outside world to access your computer.

Part 1.
First, I recommend that you turn on your computer's firewall. If you are going public, it is a good idea to remove yourself as much as possible from the outside world. In the "Sharing" pane of system preferences, click first on the "Firewall" tab, and then on "Start." Then, click on "New...," change the "Port Name" drop down to "Other," enter "80" in the "TCP Port Number(s)" field, leave the "DUP Port Number(s)" field blank, and enter "XAMPP Web Sharing" in the "Description" field.

Part 2.
Now you have to configure a static DNS address for your computer. This can be a little tricky because configuring all of this is different depending on your computer is set up. Open up the "Network" pane of system preferences. If you are connected via Built-In Ethernet, double click on "Built In Ethernet" on the network status pane. If you are connected via AirPort, double click on that. Next, click on the "TCP/IP" tab. Most likely, the drop down menu entitled "Configure IPv4" is set to "Using DHCP." Change that to "Using DHCP with manual address." Copy down the numbers located in the "IP Address" field for later use. Click on apply now, and move on to the next step.

Part 3.
Remember when I said it was going to get tricky? Its time for that to happen. In your web browser, open up your router's configuration page. If you need to, consult your router's documentation. Most Linksys routers (and I assume many other brands as well) can be found at "", though there is no guarantee. You will likely be asked for a username and password; again, I recommend you consult your router's documentation to find this information. When you reach your router's config page, you will look for a field that asks for a Static DNS address. In this field, enter the IP address that you copied down earlier and save the settings. You are almost done.

Now you have to look for a link on the router configuration page. It should be something like "Applications & Gaming," "Port Forwarding," or "Ports." If you see no such links, browse through all of the links on that page looking for something that says either "Port Range Forwarding," "Port Forwarding," or something else similarly titled. The page looks like this on my router:

You should fill out one of the rows like this:

Application = http

Start = 80

End = 80

Protocol = Both

IP Address = The IP Address you copied down earlier

These columns will probably be titled a little differently on your setup. Feel free to ask questions in the comments about this part, (or any for that matter,) and I will do my best to get back to you as quickly as I can. Guess what? You are done! How do you test it? Go to the handy little website whatismyip.com, and copy the IP address it gives you into the clipboard. It would also do you some good to memorize that IP address, or at least write it down; that is how you will access your website from other computers around the world. Paste that IP address into your browser bar, hit return, an hopefully you should get the XAMPP configuration page! You are officially online. Congratulations. Now, all you need is a real domain name.

You have to remember one thing. Every time you restart your computer, you have to restart XAMPP as well. For this, you have two options. #1, you can go to your Applications folder and there will be an Applescript called "mamppstart." Launch it, enter your password, and XAMPP is started. That wasn't too bad now, was it? Your second option is using Terminal to start it. You like adventures, don't you? Open up Terminal (Applications>Utilities>Terminal) and type the following commands:
cd /applications/xampp/xamppfiles
sudo ./mampp start
That will do the same thing the little application will do.

Well, you can now access whatever you put on the web at that magic IP address. I hope you liked this tutorial; it was the first one I have ever written. Please, drop me a note in the comments section of this page. I'd love to get some feedback. Feel free to give suggestions, criticism, fix my grammar, etc. Enjoy!



This blog will host a number of tutorials relating to running a webserver on Mac OS X. It will focus on using the XAMPP webserver, a free, open source web server that is not only easy to use, but also quite powerful. Though many of the techniques used here will work on other operating systems without trouble, I feel there are enough web pages that explain how to run a server on Windows and Linux operating systems, so this page will be focused primarily on OS X.