Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I set up a new VPS instance of Ubuntu and am wondering what the easiest way is to get up and running with a basic LAMP stack (i.e. which packages are required, which configuration options need to be tweaked, if any, etc.).

share|improve this question

14 Answers 14

up vote 98 down vote accepted
sudo apt-get update
sudo apt-get install tasksel
sudo tasksel install lamp-server

It will install all the basic LAMP stack for you, prompt for MySQL root password, etc.

More specifically it will install the following packages, and their dependencies.

mysql-client-core-5.1 libwrap0 apache2  
libaprutil1-dbd-sqlite3 tcpd  
libapache2-mod-php5 apache2.2-common  
apache2-utils php5-common  
libaprutil1-ldap libaprutil1  
php5-mysql mysql-server-core-5.1  
libdbi-perl libplrpc-perl mysql-server  
apache2.2-bin libdbd-mysql-perl  
libnet-daemon-perl libapr1  
mysql-server-5.1 libmysqlclient16  
ssl-cert apache2-mpm-prefork  
mysql-common mysql-client-5.1  

You might also want to take a peek at the Ubuntu Server Guide.

share|improve this answer
excellent answer. Thanks. – Jay Jan 2 '11 at 19:06
You might want to consider APT tasks rather than tasksel to do this. See this: Should I use tasksel, tasks in APT or install regular metapackages? – gertvdijk Jul 21 '13 at 15:15

Install Apache

sudo apt-get install apache2

Install PHP

sudo apt-get install php5 libapache2-mod-php5

As fo 16.04, the number is dropped:

sudo apt-get install php libapache2-mod-php

Install MySQL

sudo apt-get install mysql-server

Install phpMyAdmin

sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

As with the PHP installation, in 16.04, the number is dropped:

sudo apt-get install libapache2-mod-auth-mysql php-mysql phpmyadmin

Combined installation


sudo apt-get install apache2 php libapache2-mod-php mysql-server libapache2-mod-auth-mysql php-mysql phpmyadmin

Before 16.04:

sudo apt-get install apache2 php5 libapache2-mod-php5 mysql-server libapache2-mod-auth-mysql php5-mysql phpmyadmin
share|improve this answer
Note: phpMyAdmin also requires packages php-gettext and php-mbstring – Geore Shg Jun 26 at 0:52

The easiest way to install LAMP with PHPMyAdmin is using:

sudo apt-get  install lamp-server^ phpmyadmin 

You don't even need to install taskel. More details can be found here.

share|improve this answer
I'd recommend APT Tasks too. Note that the caret (^) is not a typo in this answer. See also: Should I use tasksel, tasks in APT or install regular metapackages? – gertvdijk Jul 21 '13 at 15:14
Whilst the usage of tasksel seems to be "easier", this should be the very easy way to do this task. This answer doesn't need other steps to do the job. Thank you! – Geppettvs D'Constanzo Feb 28 at 15:24

In Synaptic, click edit and mark by task. Then select LAMP Server and hit apply. Done.

share|improve this answer
+1 for providing a slightly more GUI:ish solution, even if it's not necessarily available on a VPS. – andol Jul 31 '10 at 6:25

I personally always find that installing the MySQL server and then PHPMyAdmin will install all the parts I need

sudo apt-get install mysql-server

(doing this first means it asks for the root account password to be set in advance)


sudo apt-get install phpmyadmin

It also gives you all the tools you'll need to administrate your MySQL server once it's installed :)

share|improve this answer

On commandline the simplest way is probably to use tasksel:

sudo tasksel install lamp-server
share|improve this answer

The packages are apache2 and libapache2-mod-php5. php5 has a number of additional modules, you may need some. List them with apt-cache search php5

Try revising your search or

sudo apt-get install apache2 libapache2-mod-php5

Enable php5 with

sudo a2enmod php5

Restart apache

sudo service apache2 restart

The following wiki pages can be very helpful if you are starting with apache.

Note- This answer was migrated from elsewhere. To add mysql install

sudo apt-get install mysql-server php5-mysql
share|improve this answer

It has LAMP as well as phpmyadmin integrated along with perl modules. Installs in /opt/lampp so can be installed/removed easily...

share|improve this answer

My Swiss Army knife command:

sudo apt-get install apache2 mysql-server mysql-client libapache2-mod-auth-mysql php5 php5-mysql libapache2-mod-php5 php5-mcrypt php5-curl php5-cli php5-gd phpmyadmin

share|improve this answer

PHP7.0 is standard on Ubuntu 16+

Heres the rundown:

1 As Always

 sudo apt-get update

2 Install Apache2

 sudo apt-get install apache2

3 Install mysql-server

 sudo apt-get install mysql-server

4 Install PHP 7.0

 sudo apt-get install php7.0 libapache2-mod-php7.0 php7.0-mysql php7.0-curl php-mbstring php7.0-mbstring php-gettext php7.0-json php-xml
 sudo a2enmod php7.0

5 Install phpmyadmin

 sudo apt-get install mcrypt
 sudo apt-get install phpmyadmin

Note, you'll need to add Include /etc/phpmyadmin/apache.conf to the file you'll open with the following command. (credit)

 sudo gedit /etc/apache2/apache2.conf 


 sudo a2enmod rewrite
share|improve this answer

You can install Bitnami lampstack.(Package containing all necessary sub packages of LAMP).

First of all create an account in bitnami website to download the file. Then copy the file to your desktop (for convenience ). To provide read and exicution permission, Open terminal (Ctrl + Alt + T). and type

chmod 755 chmod  755 'location of

Better drag and drop the .run file from your desktop after typing chmod 755, press enter.

Now double click on the .run file. It will guide you through the installation process.

Thank you.

share|improve this answer


sudo apt-get install tasksel && sudo tasksel install lamp-server

in terminal or over ssh and everything should setup fine. If you have any issues please leave a comment and I will further assist you with your problem.

share|improve this answer
this is a repeat answer. please elaborate to distinguish between this answer and the answer that was accepted. maybe add a link? – Malachi Mar 1 '13 at 21:33
Please Check out the FAQ – Malachi Mar 1 '13 at 21:34

I have a script for this task: lampi


sudo lampi -i -s -n -dr ~/example-site

What does it do:

  1. Install the LAMP stack (-i flag)
  2. Setup and configure apache2, mysql, php, phpmyadmin
  3. Then set up a custom site named (-n option)
  4. Set ~/example-site directory as it's document root (-dr option)
  5. Enable SSL (https) for this site (-s flag)

Now, the site can be accessed with or

share|improve this answer
Unless you post the script here i can't see any use of this answer.. – heemayl Jun 26 at 18:49
@heemayl : seriously? you want me to dump a ~350 line code here... If you are really interested, you should follow through the link and go to the github project page. – Jahid Jun 26 at 18:53
Can you guarantee that the script won't be removed in the future? Again its link only answer AFAICS. Also you should give the link to github directly, any subtle advertising is highly discouraged..Perhaps you should go through the related meta posts first.. – heemayl Jun 26 at 18:56
@heemayl : I agree on giving a direct link to github but not on it being a link only answer. I have put the code that needs to be run and explained well enough to follow through for anyone... – Jahid Jun 26 at 19:00

Try EHCP (easy hosting control panel) ...

ehcp installation on a clean server will do the dirty job for you ...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.