How to Install LAMPP in Linux

In this tutorial I will introduce you about XAMPP, a bundle of apache http server, mysql database, php and perl script language from apachefriends.org.

XAMPP also include some usefull packages, such:

  • ProFTPD 1.3.1
  • PhpMyAdmin 2.11.3
  • OpenSSL 0.9.8e
  • Webalizer 2.01
  • IMAP C-Client 2004e
  • OpenLDAP (client) 2.3.11
  • SQLite 2.8.17 (for PHP4 + PHP5)
  • SQLite 3.3.17 (for PHP5 PDO SQLite)
  • phpSQLiteAdmin 0.2
  • FPDF 1.53

Usually we need XAMPP to running our website in our home pc, not in paid server outside. So, we able to developing our website in our home offline before we upload it to online web server.

XAMPP available for many platforms, it available for Windows, MacOS and offcourse, Linux – no matter what distro you use. But in this tutorial, I will limit the tutorial in LAMPP (L stand for Linux!) only.

How To Install XAMPP/LAMPP

Download the latest LAMPP packages from http://apachefriends.org. Extract it to /opt directory as root or if you want easy to configure it, just uncompress it in your home directory.

sudo tar xvzf lampp-xxx.tar.gz /opt

NOTE:
Here I use sudo to doing something with root privilege. If your distro not support sudo by default like Ubuntu, issue su command before then enter your root password.

I myself, extract the lampp packages in my home directory on special website folder. If you take this way, follow me:

mkdir website

tar xvzf lampp-xxx.tar.gz /home/amrinz/website

and as root, we make a symbolic link (symlink/shorcut) and put it in /opt.

ln -s /home/amrinz/website/lampp /opt/lampp

Now we have finished installing XAMPP/LAMPP. Next we will learn how to use XAMPP/LAMPP.

XAMPP/LAMPP Commands

To access your web server, you must start it first. The XAMPP command formated like this:

/opt/lampp/lampp <action>

For example, use this command to start XAMPP, as root.

sudo /opt/lampp/lampp start

and to stop it, use this command

sudo /opt/lampp/lampp stop

and also some sets of actions you can use:

  • start
    Start XAMPP (Apache, MySQL and eventually others)
  • startapache
    Start only Apache
  • startssl
    Start only SSL support
  • startmysql
    Start only MySQL
  • startftp
    Start only ProFTPD
  • stopapache
    Stop only Apache
  • stopssl
    Stop only SSL support
  • stopmysql
    Stop only MySQL
  • stopftp
    Stop only ProFTPD
  • reload
    Reload XAMPP (Apache, MySQL and eventually others)
  • reloadapache
    Reload only Apache
  • reloadmysql
    Reload only MySQL
  • reloadftp
    Reload only ProFTPD
  • restart
    Stop and start XAMPP
  • security
    Check XAMPP’s security
  • php5
    Activate PHP5
  • php4
    Activate PHP4
  • phpstatus
    Which version of PHP is active?
  • backup
    Make backup file of your XAMPP config, log and data files
  • panel
    Starts graphical XAMPP control panel

To test if your installation succesfull, after start the XAMPP, acces http://localhost/wp through your web browser. You will see the XAMPP greet!

To acces another feature of XAMPP, such phpmyadmin, call it from your web browser in this url, http://localhost/wp/phpmyadmin

To change the http://localhost/wp content, go to /opt/lampp/htdocs, delete all files and directories there and change it with yours.

How To Create XAMPP Virtual Host

In this part, I will explain how to create apache virtual host.
Virtual host is apache feature which allow us to make our website with it own domain. So we can access our website through “real” url.

For example, we will make a virtual host for www.berugak.com domain.

If you installing lampp in /opt you need, again, root privilege to edit /opt/lampp/etc/httpd.conf file.

Just add this line in the last file:

include /home/username/website/extra-httpd.conf

and now, as regular user, open your editor, add these lines:

<VirtualHost 127.0.1.2>
ServerName www.berugak.com
DocumentRoot /home/amrinz/website/www.berugak.com

<Directory /home/amrinz/website/www.berugak.com>
AllowOverride All
Options All
</Directory>
</VirtualHost>

Save this file as extra-httpd.conf in /home/username/website, as we define in httpd.conf file.

Then, we must add the IP address we use above to /etc/hosts file. Just add:

127.0.1.2 www.berugak.com

In Ubuntu, you can use the Network menu. Go to System >> Administration >> Network.
Change the tab to Hosts, click Add, enter the IP address and the server name.

The last step is to create the berugak.com folder, in /home/username/website and put it with files.

You can access the new virtual host in http://localhost/wp url, as the real online website!

If you want add more virtual host, just repeat the last three steps above by changing the IP address, the server name and the directory location/name.

Mmmm, I think that enough for now. Happy dance!
🙂

Leave a Reply