How to Install LAMPP in Debian, Ubuntu, and CentOS

This is a simple tutorial about installing LAMP (Linux, Apache, MySQL, and PHP) and phpMyAdmin to help Linux newbie's to setup their own Web server. This tutorial specifically written for the following GNU/Linux distributions:

  • Debian Sarge
  • Debian Etch
  • Ubuntu Gutsy
  • Ubuntu Hardy
  • CentOS 4
  • CentOS 5

Installing LAMP in Debian Sarge

To install Apache, PHP, MySQL and phpMyAdmin in Debian Sarge, please type this command.

apt-get install apache2 libapache2-mod-php4 php4 php4-gd php4-mysql php4-cli php4-mcrypt mysql-client mysql-server libmysqlclient14-dev phpmyadmin

Installing LAMP in Debian Etch and Ubuntu Gutsy and Hardy Heron

The installation instruction for installing Apache, PHP, MySQL and phpMyAdmin in Debian Etch and Ubuntu is the same as above. The difference is in Debian Sarge, its using PHP4 and MySQL4 while in Debian Etch and Ubuntu is using PHP5 and MySQL5.

apt-get install apache2 libapache2-mod-php5 php5 php5-cli php5-mysql php5-gd php5-mcrypt mysql-client mysql-server libmysqlclient15-dev phpmyadmin

Installing LAMP in CentOS4

To install Apache, PHP, and MySQL in CentOS4 with phpMyAdmin, download and add the RPMforge repo.

wget http://packages.sw.be/packages/rpmforge-release/rpmforge-release-0.3.6-1.el4.rf.i386.rpm
rpm -ivh rpmforge-release-0.3.6-1.el4.rf.i386.rpm

We need to install RPMforge repository to install libmcrypt and phpMyAdmin using yum.
Now type:

yum install httpd php php-mysql php-gd php-mbstring mysql mysql-server mysql-devel libmcrypt phpmyadmin libtool

This will install Apache2, PHP4 and MySQL4 packages. PhpMyAdmin needs the php-mcrypt package, but it is not available in the CentOS4 repository. We will download the php-mcrypt from sourceforge.net.

wget http://downloads.sourceforge.net/phprpms/php-mcrypt-4.3.9-3.2.1.i386.rpm
rpm -ivh php-mcrypt-4.3.9-3.2.1.i386.rpm

Installing LAMP in CentOS 5

Download the RPMforge repo for CentOS5 and install Apache, PHP, MySQL and phpMyAdmin.

wget - http://packages.sw.be/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -ivh rpmforge-release-0.3.6-1.el5.rf.i386.rpm
yum install httpd php php-mysql php-gd php-mbstring php-mcrypt mysql mysql-server phpmyadmin

Configure the Apache and MySQL to run during startup in CentOS 4 and 5

chkconfig httpd on
chkconfig mysqld on
service http start
service mysqld start

To check whether your php installation is running and configured properly, create a file called "phpinfo.php" and put it in your /vaw/www/ directory for Debian/Ubuntu and /var/www/html for CentOS.
Edit the "phpinfo.php" and add this line:

<?php phpinfo(); ?>

Then open your web browser and point to http://localhost/phpinfo.php, you should see this page in your browser.

phpinfo.php

Configure phpMyAdmin in CentOS

phpmyadmin

To fix this problem, edit the file /usr/share/phpmyadmin/config.inc.php.

vi /usr/share/phpmyadmin/config.inc.php

and put a blowfish secret

$cfg['blowfish_secret'] = 'secret'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

Then refresh your browser....

phpmyadmin

Cheers!
You have now a working Linux, Apache, MySQL and PHP server.