XAMPP

From OpenComputing
Jump to: navigation, search

Contents

References

Downloads

XAMPP is a free software bundle that contains Apache HTTP web server, MySQL server, PHP interpreter, phpMyAdmin, and other software.

The current version of XAMPP is 1.8.1 as of March 1, 2013.

Currently, four distributions are available as follows: Windows, Linux, Mac OSX, and Solaris.

Windows Installation

Where to Install

Precondition for Windows developers: You have downloaded XAMPP or XAMPP USB Lite 1.8.1 to your computer.

Choices:

  • Install on a hard drive
  • Install on flash drive

Flash drive installation pros

You'll have an entirely portable web server in your pocket, add your favorite browser to the flash drive, and you can plug it into almost any computer and run it.

Flash drive installation cons

It's quite common that you'll unplug your USB flash drive before you stop either the web server or MySQL server. The speed of the USB protocol that your computer or flash drive supports affects the performance of your web apps 'on the stick'.

Important Note: You need to make sure the ports 80 and 3306 are free. These ports can be blocked for several reasons; firewalls, antivirus, Skype, IIS, etc.

Hard Drive Installation

  • 1. Download the XAMPP Installer.
  • 2. Run installer and choose the location you would like to install XAMPP at (such as C:\xampp\).
  • 3. When installation is completed, XAMPP will be found under under Start menu> Programs > XAMPP as well as in the location you choose to install it on your hard drive.

USB Lite Installation

  • Locate the self-extracting archive XAMPP USB Lite file on your computer and double click on it.
  • It opens a menu asking for your primary language. The installer defaults to English. Once you have selected your language click OK to continue.
  • When prompted that a USB drive be needed, click OK. Do not worry as it can be installed to the hard drive.
  • The installer shows a welcoming message. Click Next.
  • Select where you want to install XAMPP. It defaults to C:\xampp which is the recommended location if you are doing a hard drive installation. If you are doing a flash drive install, browse to the flash drive and install there. It is suggested to use the root folder of the flash drive.
  • After the destination folder has been selected, click Install to begin the installation process. It will take a few minutes to install. A terminal window will be opened during installation. Do not close the window as it will automatically close by itself.
  • When installation is complete, click Finish, and you're done!

Testing Windows Install

How do you know it works?

  • Go to the xampp directory on the hard drive, c:\xampp (or flash drive).
  • At the bottom of the list of files in the xampp directory, there is an executable called xampp-control.exe'.
  • Double click xampp-control.exe file to open the control panel for XAMPP.

Xamppcontrol.png

The control panel shows two applications that can be started or stopped from the XAMPP control panel: Apache and MySQL.

Testing Apache web server application

  • Start Apache by clicking the Start button associated with it in the XAMPP control panel.
  • Open a browser and type
    http://localhost
    into the address bar.
  • A XAMPP page with selection of languages is displayed. Click on English. It will display a welcome page.
  • Click "Status" on the left side bar to be sure all services are running.
  • Close the browser and stop the Apache server application from the XAMPP control panel.

Testing MySQL database server application

  • Start MySQL by clicking the Start button associated with it in the XAMPP control panel.
  • Open a command prompt (cmd in Windows), change directory to where the mysql utility is located, and connect to the MySQL server using -u root option for mysql utility.

Example

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\mcs>cd c:\xampp\mysql\bin
c:\xampp\mysql\bin>dir
 Volume in drive C is Local Disk
 Volume Serial Number is 7404-9C40

 Directory of c:\xampp\mysql\bin

02/12/2012  01:32 PM    <DIR>          .
02/12/2012  01:32 PM    <DIR>          ..
09/09/2011  01:43 PM           146,944 echo.exe
02/12/2012  01:32 PM             5,396 my.ini
09/09/2011  01:44 PM         3,848,704 myisamchk.exe
09/09/2011  01:44 PM         3,724,800 myisamlog.exe
09/09/2011  01:44 PM         3,764,736 myisampack.exe
09/09/2011  01:44 PM         3,737,088 myisam_ftdump.exe
09/09/2011  01:44 PM         4,107,776 mysql.exe
09/09/2011  01:44 PM         4,040,192 mysqladmin.exe
09/09/2011  01:44 PM         4,133,376 mysqlbinlog.exe
09/09/2011  01:44 PM         4,035,072 mysqlcheck.exe
09/09/2011  01:42 PM        13,582,848 mysqld-debug.exe
09/09/2011  01:46 PM         8,158,720 mysqld.exe
09/09/2011  01:44 PM         4,096,512 mysqldump.exe
09/09/2011  01:40 PM             7,614 mysqldumpslow.pl
09/09/2011  01:40 PM            24,528 mysqld_multi.pl
09/09/2011  01:40 PM            33,927 mysqlhotcopy.pl
09/09/2011  01:44 PM         4,029,440 mysqlimport.exe
09/09/2011  01:44 PM         4,029,952 mysqlshow.exe
09/09/2011  01:44 PM         4,051,968 mysqlslap.exe
09/09/2011  01:44 PM         4,248,064 mysqltest.exe
09/09/2011  01:46 PM         8,958,464 mysqltest_embedded.exe
09/09/2011  01:44 PM         4,462,080 mysql_client_test.exe
09/09/2011  01:46 PM         9,212,416 mysql_client_test_embedded.exe
09/09/2011  01:40 PM             8,792 mysql_config.pl
09/09/2011  01:40 PM             4,413 mysql_convert_table_format.pl
09/09/2011  01:46 PM         8,848,384 mysql_embedded.exe
09/09/2011  01:44 PM         3,470,848 mysql_plugin.exe
09/09/2011  01:40 PM             9,432 mysql_secure_installation.pl
09/09/2011  01:43 PM         3,432,960 mysql_tzinfo_to_sql.exe
09/09/2011  01:44 PM         3,548,672 mysql_upgrade.exe
09/09/2011  01:43 PM         3,456,512 my_print_defaults.exe
09/09/2011  01:44 PM         3,548,160 perror.exe
09/09/2011  01:43 PM         3,445,760 replace.exe
09/09/2011  01:43 PM         3,454,976 resolveip.exe
              34 File(s)    129,669,526 bytes
               2 Dir(s)  29,450,244,096 bytes free

c:\xampp\mysql\bin>mysql -u root
  • If successful, you are prompted with:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.5.16 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
  • Exit the command prompt and stop MySQL server from the XAMP control panel.

Mac Installation

For computers running Mac OS X, the only option available is the full package (version 1.7.3).

The process is as follows:

  • 1. Download the XAMPP program from the link above.
  • 2. Open the DMG file in your downloads folder
  • 3. Drag and drop the XAMPP file to the Applications folder on your Hard Drive.

Testing Mac Install

To test to make sure your installation of XAMPP works, follow these steps:

For MySQL:

  • 1. Open XAMPP Control.
  • 2. Click start button next to MySQL and enter your computer's admin password.
  • 3. Open up the Terminal app (Applications> Utilities)
  • 4. Find the MySQL db file (XAMPP > xampp files > bin).

Mysqlicon2.png

  • 5. Select the file and do File > Get Info (or Apple -I).
  • 6. Copy the "Where:" file path into the terminal and then enter /mysql -u root -p

Xampppath.png

  • 7. If you get a welcome message (the image below). MySQL is now functional.

MySQL Welcome Msg


For Apache and PHP:

  • 1. Open XAMPP Control.
  • 2. Click start button next to Apache and enter your computer's admin password.
  • 3. Type "http://localhost/~[your user/computer's name]" into whatever web browser you use (Note: Mac OS X will read any site saved in your sites folder [Home icon with user/computer name > Sites]. Do not use the XAMPP htdocs folder).
  • 4. If you get a Mac OS X page that talks about how Mac is ready to use Apache, then your setup is successful.

Troubleshooting

Disable IIS

In Windows, if you type http://localhost and get a screen that says IIS, you'll need to disable IIS.

  • Go to Start and select Control Panel.
  • Find the option to remove a program and select it. In Windows 7, it's Start->Control Panel->Programs and Features->Uninstall or change a program.
  • A list of installed program is displayed.
  • Find Internet Information Services and uninstall it.
  • Windows might need a restart after this and it's possible you'll need to reinstall XAMPP.

Disable Skype usage of port 80 and port 443

If you have Skype installed by default, it is set up to use port 80, which is also needed by the Apache server for the HTTP requests. Apache server also uses port 443 for the HTTPS requests.

  • Open the Skype window.
  • Click on Tools menu and select Options.
  • Click on Advanced tab.
  • Go to Connection sub-tab.
  • Un-tick the check box for Use port 80 and 443 as an alternatives for incoming connections option.
  • Click on Save button and then restart Skype to make the change effective.

Unblocking XAMPP ports

Does your Apache turn on for a short time, and then turn off again? It could be because of a port conflict. Other programs can use ports needed by XMAPP.

Go to the XAMPP control panel and click the port check button. It should tell you which ports are blocked or used and the offending program using the port.

Find port conflicts

  • Go into the xampp/installdirectory.
  • Run portcheck.bat, which will output a file called portcheck.ini.
  • Examine the content of portcheck.ini file. It shows you what ports XAMPP was unable to bind to.
c:\xampp\install>type portcheck.ini | more
[Ports]
Port80=BLOCKED
Port443=BLOCKED
Port3306=BLOCKED
Port21=FREE
Port14147=FREE
Port8080=FREE

Find Windows processes that use conflicting ports

  • Open up a command prompt window and type:
netstat -o -n -a | findstr 0.0:443
, if you want to check the processes that are using port 443. Replace 443 with any other conflicting port number.
  • You get the process ID of the application using the port. Record the process ID(s).
  • Open up the Windows Task Manager utility with Ctrl+Shift+Esc short key, and view the processes by clicking on its tab.
  • Go to View -> Select Columns... and select PID (process identifier) from that list.
  • If you click the PID column heading, PID numbers will arrange in ascending or descending order. Find the process ID in the PID column that matches the number you recorded in a previous step.
  • With the name of the conflicted process, you can either stop the application or change the port that XAMPP is trying to use.
    • In my case, port 443 was being used by VMWare. Since I don't want to stop VMWare's background service, I'll simply change Apache's config to use something other than port 443 by editing X:\xampp\apache\extra\httpd-ssl.conf

Document Root Set Up

What is a web server?

A web server is a computer program that delivers content using the Hypertext Transfer Protocol (HTTP) and SSL-encrypted HTTP (HTTPS).

The term web server can also refer to a host computer, virtual machine, or device connected to a network and running a web server program.

XAMPP's web server program is Apache.

What is a "document root"?

A document root is the directory from which the Apache server serves web pages.

By default, XAMPP configuration has the c:\xampp\apache\htdocs directory set up to be the "document root". It is good practice to designate another folder as "document root", whether you do web app development or deploy a web app for production.

Refer to the Apache wiki page to learn how to create an alternative web directory and set up aliases for it.