What's the easiest way to set up a LAMP stack?

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.).


Solution 1:

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  
libhtml-template-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.

Solution 2:

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

16.04:

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

Solution 3:

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, which gives this:

To access PHPMyAdmin, open terminal & type:

sudo -H gedit /etc/apache2/apache2.conf

Add this line somewhere in that file:

Include /etc/phpmyadmin/apache.conf 

Finally restart Apache using:

/etc/init.d/apache2 restart

or

sudo service apache2 restart

Solution 4:

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

Solution 5:

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)

then

sudo apt-get install phpmyadmin

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