(+91) 9717862542

blogpost

Installing Apache, PHP, MySQL and phpMyAdmin from XAMPP

XAMPP is an all-in-one package that you can use to install Apache, PHP, and MySQL. XAMPP also installs phpMyAdmin, a Web application used to administer MySQL. XAMPP installs all the packages in one easy procedure. XAMPP installation instructions are provided for Windows and Mac.

Installing XAMPP on Windows

  1. Go to www.apachefriends.org/en/xampp-windows.html.
  2. Scroll down to the Download section, shown below:

    xampp download page

  3. Click the Installer link under the Basic Package listing to download the installer version. The downloaded file is named xampp-win32-1.6.4-installer.exe. Save the downloaded file on your hard disk or desktop.
  4. Navigate to the location where you saved the downloaded XAMPP file.
  5. Double-click the file name. The Installation Wizard starts.
  6. Read and click through the next few windows until the Choose Install Location screen appears, as shown below.

    xampp install

    It's best to accept the default location (c:\xampp) unless you have a really good reason to choose another location. If you are installing on Vista, you cannot install in the Program Files folder because of a protection problem. Also, PHP sometimes has a problem if it is installed in a folder with a space in the path, such a Program Files.

    You can click Browse to select another install folder. When you have chosen the install folder, click Next. The XAMPP Options screen appears.

  7. Under the "SERVICE SECTION", check Apache and MySQL, as shown below. This installs the tools as Windows services.

    xampp install

  8. Click Install. The installation process takes a few minutes to complete. As the installation proceeds, you will see various files/components being installed on your system, in the location you specified. A status bar shows the installation progress. When the installation is complete, the Installation Complete screen appears, as shown below.

    xampp install

    A small panel with messages may appear, as shown. If so, click OK.

  9. Click Finish.

To test your installation, open the XAMPP control panel. When the control panel is running, its icon xampp icon is in your system tray. You can click the icon to open the Control Panel. If you do not have the icon in your system tray, you can start the Control panel from the start menu by choosing the following:

   Start->All Programs->Apache Friends->XAMPP->XAMPP Control Panel

If you attempt to start the Control Panel when it is already running, as shown by the icon in your system tray, an error message is displayed.

The open Control Panel with Apache and MySQL running is shown below.

xampp control panel

This status means your development environment is ready for work. If the status of Apache and MySQL is Running but the SVC box is not checked, you can use Apache and MySQL, but they will stop when your computer is shut down. You will have to restart them in the XAMPP Control Panel every time you start your computer. It's better to run them as a service so that they will start automatically whenever your computer starts.

 

XAMPP works well in all the major platforms: Windows, Mac and Linux.

After you install XAMPP,

  1. Open any Text Editor.
    Install new if you don't already have any good Text Editor installed. (My Favorite is Sublime Text & Notepad++)
  2. Write the following PHP Program / CODE in the Text Editor:
    <?PHP
    echo 'I know how to run a PHP Program in XAMPP! <br />';
    ?>
    This is test.php File.
  3. Save the file in XAMPP Installation Directory \ Web Root Directory
    Note-1: Default XAMPP Installation Directory in Windows is C:\xampp
    Note-2: Default Web Root Directory in XAMPP is htdocs. All your php files will have to be in this htdocs folder.
    That means, for a typical installation of XAMPP in Windows, you will have to save the PHP CODE in C:\xampp\htdocs folder.
  4. When you save the file, name it test.php (just as an example, any valid file name with .php in the end will work).
    Note: when you save this file, make sure it has no .txt extension at the end. Some text editors place .txt at the end of file name, so it becomes test.php.txt instead of test.php. To avoid this, when you save the file using any text editor, place double quote around the file name: e.g. "test.php"
  5. Then, go to XAMPP installation folder (typically, C:\xampp) and run xampp-control.exe by double clicking it.
  6. In the xampp-control window, click the start button beside Apache. Later, if you need other options like MySQL, you'll also have to start MySQL by clicking the start button beside MySQL in the XAMPP control Panel.
    Note: if your OS hides common file extensions, then you'll see xampp-control, instead of xampp-control.exe
  7. Now, in your web browser's address bar, type the address: http://localhost/test.php

If your test PHP file is working properly, then you should see the following two lines in your browser:

I know how to run a PHP Program in XAMPP!
This is test.php File.

If PHP is NOT working (but the web server Apache is working), in that case only the following one line result will appear:

This is test.php File.

If none of the above is happening, then you are doing something wrong somewhere else.

So now you know how to run PHP Program in XAMPP. It is time to learn some web development with PHP! Happy Coding 🙂