How to: Tips and Tricks

4 easiest ways to install LAMP server on Ubuntu

In this guide I will show you the easiest way, how to install a LAMP server. LAMP stands for Linux, Apache, MySQL, PHP. There are many methods to install LAMP, for example the standart one see this howto for ubuntu: Howto: Install LAMP and phpMyAdmin on Ubuntu

Method One (using Terminal)

Under Terminal type command:

sudo tasksel

Select LAMP server and hit OK

Tasksel - select LAMP server

If prompted, insert new root password for the MySQL

Tasksel - root password for MySQL

Method Two (using Terminal)

sudo tasksel install lamp-server

Method Three (using Terminal)

sudo apt-get install php5 apache2 mysql-server

Method Four (using Synaptic Package Manager)

Run System > Administration > Synaptic Package Manager and select Edit > Mark Packages by Task…

Edit - Mark packages by task

Select LAMP server

Select LAMP server

In the next step you can see packages, that would be installed

Packages, that would be installed

Enter new password for the MySQL root user

Enter new MySQL root password

and that's it..

Testing Apache

Open a web browser and enter the address http://localhost. You should see a webpage displaying the text "It Works!"

Apache - It Works

Testing PHP

To test our PHP installation we need to create file called info.php in /var/www. Open Terminal and enter:

sudo gedit /var/www/info.php

Enter the line below, save the file, and exit the text editor.

<?
phpinfo();
?>

Restart apache

sudo /etc/init.d/apache2 restart

Now, open your browser and enter http://localhost/info.php. You should see a bunch of information about your version of PHP.

PHP info

Optional

phpMyAdmin

This step is optional. To easy access MySQL databases use phpMyAdmin.

Under Terminal enter this command to install phpMyAdmin

sudo apt-get install phpmyadmin

If prompted, use the spacebar to mark apache2 and then hit Enter.

phpMyAdmin - select apache2

You will also be asked if you want to configure phpMyAdmin with a new database called dbconfig-common. Select Yes and press Enter.

phpMyAdmin - dbconfig-common

Next you'll be prompted for the password for MySQL's administrator. Enter the MySQL root password that you created earlier in the installation. Select Yes and press Enter.

Next you'll be prompted to create an application password for phpMyAdmin to talk to MySQL. If you leave it blank, a random password will be generated for you.

After configuring the password, the installation should complete.

Testing MySQL (phpMyAdmin)

Open a web browser and enter the address http://localhost/phpmyadmin.You should see this page:

phpMyAdmin - login

Login using the username root and the root password, that you created earlier.

phpMyAdmin - admin

The LAMP server is successfully installed.

  • thanks a lot

  • I used method 2

    sudo tasksel install lamp-server, then what? HOW DO I RUN IT?????!!!

  • Hello, can you show how to autostart apache?

  • info.php not opening anything. it just stands there with a white blank page. not even a 404 error. nothing. what’s wrong? is php installed properly?

  • white page in php, also called white page of death, means you have some error in your info.php and you have turned off showing php errors. Check info.php first. Secondly look in your /var/log/ for apache or httpd error logs. And don’t forget to turn on showing errors in your vhost file.