August 29, 2009

Easiest way to get LAMP (Linux, Apache, MySQL, PHP) up and running on Linux

I guess most of the people already know how to set up LAMP (Linux Apache MySQL PHP) environment on Linux still most of us face issues while trying to install it on a old linux distribution like red hat or enterprise linux.

I found a working method of installing LAMP on linux and it's as easy as it gets. The complete package is here:

The downloadable package and exact instructions are given here:

Basically, we just need to extract the package! no installation is required. For e.g. the package can be installed in /opt directory using the following command:

$ sudo tar zxvf xampp-linux-*.gz -C /opt

Before running xampp, stop your existing apache, mysql server.

The PATH environment variable needs to be set correctly. If the package is extracted in /opt, then the PATH variable should be set as:

$ export PATH=/opt/lampp/bin:$PATH

The above line can be added to .bashrc file in the home directory so that the correct path will be set for every shell.

If the linux machine is rebooted, xampp needs to be started manually. To start xampp by default when the machine boots, enter the following commands (as root):

$ cd /etc/rc.d/rc5.d
$ ln -s /opt/lampp/lampp S99lampp
$ ln -s /opt/lampp/lampp K01lampp

Here, we are adding the scripts to start xampp to the default runlevel (5 in this case). Runlevel 5 is for GUI boot. Whatver we add to the /etc/rc.d/rc5.d folder will be started by default when the system boots.

Also, ensure that if you already have an existing MySQL, Apache installation, disable it to start everytime using the following command (as root):

$ ntsysv

This will open up a shell GUI, where you will have to de-select mysql and httpd (apache). By de-selecting these options we ensure that these services are not started by default on boot since we are already using xampp to start mysql and apache.

I hope this information helps someone.