Custom Search

Friday 7 October 2011

Install LAMP in UBUNTU

 This is to help people setup and install a LAMP (Linux-Apache-MySQL-PHP) server in Ubuntu, including Apache 2, PHP 5 (optionally PHP 4 in Ubuntu 6.10 and lower), and MySQL 4.1 or 5.0.

When installing from the Ubuntu 6.06 (Dapper Drake) "Server cd", you have the option of choosing to install a LAMP setup at the inital Ubuntu installation screen. That will install apache2, php5 and mysql 5.0.

Check Requirements

{i} As of Ubuntu 7.04 (Feisty), all PHP4 packages have been dropped from the repositories, as the PHP4 branch is not being further developed/supported by the PHP Group. Everything in this article pertaining to PHP4 can therefore only be executed in Ubuntu 6.10 and lower. If you absolutely depend on PHP4 and would like to use the current Ubuntu release, you have to compile it from source.

Some applications require php4 while others will work with php5. Be sure to install the version of php and the corresponding apache2 module for it. You cannot have both php4 and php5 modules running on the same instance of apache2 at the same time. Installing one may remove the other.

If you have both php4 and php5 installed, be aware of which version of the apache2 php module you have. If libapache2-mod-php5 is already installed, the php4 package will install libapache-mod-php4 and not libapache2-mod-php4 package.

If libapache2-mod-php5 is not installed, installing php4 will install the apache2 php module (libapache2-mod-php4). See this example.

Most web applications will use Apache2, php5 and mysql5.0. If no specific versions are mentioned in your web application's documentation, use those.

To install the default LAMP stack in Ubuntu 6.06 LTS (Dapper Drake)

If you did not use the LAMP installer option from the server cd but want to install those same packages without having to reinstall your operating system, use any method to install the following packages

apache2 php5-mysql libapache2-mod-php5 mysql-server

All of those packages are in the Ubuntu 6.06 LTS (Dapper Drake) main repository. Once LAMP is installed, you need to set a mysql root password and then, depending on your web application, create a database, user and password. That's it!

To install the default LAMP stack in Ubuntu 7.04 (Feisty Fawn) Ubuntu 7.10 (Gutsy Gibbon) Ubuntu 8.04 LTS (Hardy Heron), 8.10 (Intrepid Ibex), 9.04 (Jaunty Jackalope), 9.10 (Karmic Koala), 10.04 (Lucid Lynx) and 11.04 (Natty Narwhal)

As of the 7.04 release, the Ubuntu base system includes Tasksel.

{i} Ubuntu 11.04 base system does not include tasksel. You will need to install it.

sudo apt-get install tasksel

You can either install LAMP using tasksel or install the LAMP packages as detailed above.

sudo tasksel install lamp-server

See Tasksel - be warned, only use tasksel to install tasks, not to remove them - see https://launchpad.net/bugs/574287

Starting over, How to remove the LAMP stack

To remove the LAMP stack remove the following packages:

    * Note: This assumes you have no other programs that require any of these packages. You might wish to simulate this removal first, and only remove the packages that don't cause removal of something desired.

apache2 apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libdbd-mysql-perl libdbi-perl libmysqlclient15off libnet-daemon-perl libplrpc-perl libpq5 mysql-client-5.0 mysql-common mysql-server mysql-server-5.0 php5-common php5-mysql

To also remove the debconf data, use the purge option when removing. To get rid of any configurations you may have made to apache, manually remove the /etc/apache2 directory once the packages have been removed.

No comments:

Post a Comment