How to Install XAMPP on Ubuntu Linux

This is an important tutorial on how to install and completely configure XAMPP to run without problems on Ubuntu Linux.

To proceed please make sure you have the following requirements:

  • Linux Ubuntu operating system – This tutorial has been written using Ubuntu 9.10 – Karmic Koala.
  • XAMPP Linux Version installer – You can go to the XAMPP Linux Page and use the actual download link

At the time this tutorial was written, the latest XAMPP version for Linux was 1.7.3a. If the download link won’t work, go to the XAMPP Linux page.

This installation using the latest release will enable you to make PHP-based websites (to be tested locally using Linux XAMPP) that have the following important features:

  • PHP 5.3.1
  • Apache 2.2.14
  • MySQL 5.1.41
  • phpMyAdmin 3.2.4

Step 1: Run the Installer in Linux Ubuntu

First things first. After you download the XAMPP installer for Linux, you need to check the integrity of the installer by checking the MD5 Checksum of the downloaded installer and comparing it with the correct one. If they are not the same, the installer you have downloaded may be “corrupt” or “incomplete;” hence, it will not run properly when installed.

You can get the “correct value” of the MD5 checksum on the XAMPP Linux Page: http://www.apachefriends.org/en/xampp-linux.html

See the screen shot below of where you can find the “correct value” of the MD5 checksum (inside the box):

Now, using the Linux terminal (Applications – Accessories – Terminal), go to the Ubuntu download directory: cd Downloads, actual command: (Important: In this tutorial, the bold blue font phrase is the actual terminal “command” entered while the rest are part of the Linux prompt):

codex-m@codex-m-desktop:~$ cd Downloads

Log in as root, type this in the terminal, and then enter your Linux password:

sudo -s -H

Actual command:

codex-m@codex-m-desktop:~/Downloads$ sudo -s -H  

Next, type in the terminal: md5sum xamppinstallername.tar.gz

Replace xamppinstaller.tar.gz with the actual file name of the downloaded archived installer. In this case, that would be xampp-linux-1.7.3a.tar.gz

Below is the actual terminal command and its result (red is the actual md5sum):

root@codex-m-desktop:/home/codex-m/Downloads# md5sum xampp-linux-1.7.3a.tar.gz

89c13779cf6f0925d5c1c400d31a1cc3  xampp-linux-1.7.3a.tar.gz

And here is the correct value based on the XAMPP Linux page (screen shot earlier) :

89c13779cf6f0925d5c1c400d31a1cc3

The Md5sum matches, and the installer is OK.

The next step assumes you are still on the Ubuntu Download Directory (my path is: /home/codex-m/Downloads) and still logged in as root. Into the terminal, enter the command below:

root@codex-m-desktop:/home/codex-m/Downloads# tar xvfz xampp-linux-1.7.3a.tar.gz -C /opt

Double check that the syntax is correct before proceeding, and then press enter. Linux will extract the files in the archive and place them in the /opt/ path on your Linux computer.

After this is done, reboot your computer with:

root@codex-m-desktop:/home/codex-m/Downloads# sudo reboot 

The third step in this process is to verify your installation. Log in in as root again, and then try starting XAMPP. You should not see any errors. (Below is an example of a successful installation; remember the bold part is the actual command to start XAMPP):

root@codex-m-desktop:/home/codex-m# /opt/lampp/lampp start

Starting XAMPP for Linux 1.7.3a…

XAMPP: Starting Apache with SSL (and PHP5)…

XAMPP: Starting MySQL…

XAMPP: Starting ProFTPD…

XAMPP for Linux started.

{mospagebreak title=Step 2: Change the Owner to Your Own Linux Account}

By default, if you are using Linux, you are not the root unless you log in as root. This can be difficult when editing, saving and writing files to /opt/ directory (where XAMPP has been installed). This is because the owner of that is still not you; it is the root.

You need to configure a change of ownership so that you will own your files that will be saved in the HTDOCS directory (the directory where you will save your PHP files for testing in the web browser). To do this, go through the steps below in order.

1. In terminal, log in as root and then go to the /opt/lampp directory:

Actual command: root@codex-m-desktop:/home/codex-m# cd /opt/lampp

2.) Enter ls -l

Actual command (last is Letter L): root@codex-m-desktop:/opt/lampp# ls -l

Linux will list the owners of the file and directories. Note that htdocs is owned by nobody – root

3. To change the owner from nobody — root to your own Linux Ubuntu username:

chown -R yourlinuxusername:yourlinuxusername htdocs

My Linux username is: codex-m, so for me, the actual command is:

root@codex-m-desktop:/opt/lampp# chown -R codex-m:codex-m htdocs

4. You also need to associate ownership of your Linux username with the Apache configuration. In this case type cd etc in the terminal:

Actual command: root@codex-m-desktop:/opt/lampp# cd etc

5. Now you are in the etc directory. Type pico httpd.conf. This will show the Linux text editor in the terminal:

Actual command: root@codex-m-desktop:/opt/lampp/etc# pico httpd.conf

Be careful when editing; a single mistake can make the Apache web server inoperable. So find the line:

User nobody

Group nogroup

</IfModule>

</IfModule>

Change this to:

User codex-m

Group nogroup

</IfModule>

</IfModule>

Of course, you need to replace my Linux username (codex-m) with your own username. If you are done editing, press Control – O, to save. And when it displays:

File name to write: httpd.conf

Press the Enter key and it’s done. Press Control – X to exit the editor.

{mospagebreak title=Step 3: Browser Configuration in XAMPP}

The next important thing after changing ownership is to confirm three things. First, that XAMPP works nicely with a web browser; second, that the proper language (yours) is selected; and third, that the MySQL databases (phpMyAdmin) are configured. To accomplish these objectives, go through the sequence of steps below. 

First, go to the Linux root directory. Here is the actual command:

root@codex-m-desktop:/opt/lampp/etc# cd /

Second, restart XAMPP in the Linux terminal (/opt/lampp/lampp restart). Here is the actual command and result (make sure you do not see any errors):

root@codex-m-desktop:/# /opt/lampp/lampp restart

Stopping XAMPP for Linux 1.7.3a…

XAMPP: Stopping Apache with SSL…

XAMPP: Stopping MySQL…

XAMPP: Stopping ProFTPD…

XAMPP stopped.

Starting XAMPP for Linux 1.7.3a…

XAMPP: Starting Apache with SSL (and PHP5)…

XAMPP: Starting MySQL…

XAMPP: Starting ProFTPD…

XAMPP for Linux started.  

Third, open the Firefox web browser and in the address bar enter:

http://localhost

Fourth, when the XAMPP splash page has been displayed, select your language. You should then see the following message on the system: 

You successfully installed XAMPP on this system!

Fifth, in the tools at the XAMPP navigation menu, click phpMyAdmin.

You will then see an error: Existing configuration file (./config.inc.php) is not readable.

This is because the affected file of this error config.inc.php is not set to your Linux username. To fix this, in the Linux terminal, go to /opt/lampp/phpmyadmin directory. Here is the actual command:

root@codex-m-desktop:/# cd /opt/lampp/phpmyadmin

Now that you are in the phpmyadmin directory, you need to set the ownership of the file config.inc.php to your own Linux username (replace my username with yours). Here is the actual command:

root@codex-m-desktop:/opt/lampp/phpmyadmin# chown codex-m:codex-m config.inc.php

{mospagebreak title=Step 4: Configure Linux XAMPP Security}

First, log in as root. Then go to your Linux root directory (/) and type:

/opt/lampp/lampp security

Answer “YES” to all and type the password. You cannot see it while typing, but XAMPP will verify it. Here is the actual series of commands in the Linux terminal:

root@codex-m-desktop:/opt/lampp/phpmyadmin# cd /

root@codex-m-desktop:/# /opt/lampp/lampp security

XAMPP: Quick security check…

XAMPP: Your XAMPP pages are NOT secured by a password.

XAMPP: Do you want to set a password? [yes] yes

XAMPP: Password:

XAMPP: Password (again):

XAMPP: Password protection active. Please use ‘lampp’ as user name!

XAMPP: The MySQL/phpMyAdmin user pma has no password set!!!

XAMPP: Do you want to set a password? [yes] yes

XAMPP: Password:

XAMPP: Password (again):

XAMPP: Setting new MySQL pma password.

XAMPP: Setting phpMyAdmin’s pma password to the new one.

XAMPP: MySQL has no root password set!!!

XAMPP: Do you want to set a password? [yes] yes

XAMPP: Write the password somewhere down to make sure you won’t forget it!!!

XAMPP: Password:

XAMPP: Password (again):

XAMPP: Setting new MySQL root password.

XAMPP: Change phpMyAdmin’s authentication method.

XAMPP: The FTP password for user ‘nobody’ is still set to ‘lampp’.

XAMPP: Do you want to change the password? [yes] yes

XAMPP: Password:

XAMPP: Password (again):

XAMPP: Reload ProFTPD…

XAMPP: Done.

Since there is a database configuration file alteration, you need to change the ownership back to your username (it’s the same process you went through in the earlier section):

In the Linux terminal:

root@codex-m-desktop:/# cd /opt/lampp/phpmyadmin

root@codex-m-desktop:/opt/lampp/phpmyadmin# chown codex-m:codex-m config.inc.php

Finally restart XAMPP Again with /opt/lampp/lampp restart

 Here is the actual command:

root@codex-m-desktop:/# /opt/lampp/lampp restart

Stopping XAMPP for Linux 1.7.3a…

XAMPP: Stopping Apache with SSL…

XAMPP: Stopping MySQL…

XAMPP: Stopping ProFTPD…

XAMPP stopped.

Starting XAMPP for Linux 1.7.3a…

XAMPP: Starting Apache with SSL (and PHP5)…

XAMPP: Starting MySQL…

XAMPP: Starting ProFTPD…

XAMPP for Linux started.

You should not see any error.

{mospagebreak title=Step 5: Test Your Overall Installation Process}

You are almost finished! You need to double-check your XAMPP installation using the process below.

1. Clear your entire browsing history and cache. In Firefox: Tools – Clear Recent History – set to “Everything” and check all options available. Then click “Clear Now.”

2. Visit http://localhost, and log in with your XAMPP username/password that you configured in the earlier section. If you are able to log in without error, your login configuration is correct.

3. Click the phpMyAdmin link again in the XAMPP menu. You should now be able to see the phpMyAdmin login page since you already changed the ownership of the config.inc.php file in the earlier section. Try logging in with your MySQL username and password. You should not see any errors.

Important: the MySQL database in phpMyAdmin has two accounts, one with pma as the usename, while the other uses root as the username. Both are accessible using the same passwords.

If you were successful in this step, congratulations. You have completely installed and configured XAMPP to run in Ubuntu under your own username. If your computer is configured to have a Windows XP dual boot with Ubuntu, you can create a backup of your Windows-based XAMPP htdocs files to your Linux XAMPP htdocs, with its corresponding databases.

Important: do not overwrite or delete these following important default files inside your htdocs:

  • webalizer
  • xampp
  • favicon.ico
  • index.php

They are installed by default and needed for normal operation.

Tip: To start XAMPP automatically after any reboot or computer restart (as in Windows), follow the procedure below.

1. Launch the Linux terminal and log in in as root.

2. Enter the following commands one after another:

sudo ln -s /opt/lampp/lampp /etc/init.d/lampp
sudo update-rc.d -f lampp defaults

Please refer here for details: http://ubuntuforums.org/showthread.php?t=476403

Google+ Comments

Google+ Comments