Home » Systems » Ubuntu » Installing LAMP in Ubuntu

Installing LAMP in Ubuntu

Installing LAMP (Linux, Apache, MySQL, PHP) is easy!

Hands down LAMP is one of the most useful and easily installed comprehensive like stack that you can install in Ubuntu.

There are a few ways to install LAMP on Ubuntu. Through a apt-get or the tasksel method.

Before we do that though you should check to see if you have LAMP already installed or portions of the stack!

If you know you don’t have it installed skip down to one of the two methods of installing LAMP!

After we install LAMP we will test each portion of the stack to make sure it is working properly.

You can now begin installing LAMP with the guide below.

 

Check to see if anything is already installed (By Checking for versions)

Checking for apache2:

/usr/sbin/apache2 -V

Checking for PHP:

php -v

Checking for MySQL:

mysql -u root -p

select version();

1st way of installing LAMP (apt-get)

Here is the first way you can install LAMP.

sudo apt-get install lamp-server^

It will eventually get to a point where you need to give MySQL a password. (doesn’t have to be the same password as your Ubuntu login)

Once Ubuntu initializes all of the settings you will that you are done installing LAMP; which will bring you back to the command prompt.

Added gallery for support below.

2nd way of installing LAMP (Tasksel)

It is also possible to install LAMP with tasksel. Tasksel is installed by default on Ubuntu Server editions but not the Ubuntu Desktop edition.

If you have Ubuntu Server follow these steps for installing LAMP:

sudo apt-get install tasksel

It will eventually get to a point where you need to give MySQL a password. (doesn’t have to be the same password as your Ubuntu login)

Once Ubuntu initializes all of the settings you will know it is complete once you are back at the command prompt.

If you have Ubuntu Desktop follow these steps for installing Tasksel and LAMP:

sudo apt-get install tasksel

sudo tasksel install lamp-server

It will eventually get to a point where you need to give MySQL a password. (doesn’t have to be the same password as your Ubuntu login)

Once Ubuntu initializes all of the settings you will know it is complete once you are back at the command prompt.

Added gallery for support below.

Testing your installation (Apache2, PHP, MySQL)

1. First lets test out apache2. Open up a web browser of your choice and browse to:

http://localhost/ or http://IPOFYOURSERVER/ 

Note: Only use localhost if you on that computer at this time or else you won’t see anything as you are browsing locally!

You will end up to a page similar to this, if you do that means your apache2 works!

draalin-installing-lamp-1

 

2. Now lets test out your PHP. The easiest way to test out PHP is to create a file that displays PHP information.

You can do this by creating a file with any name, but for this case we will call it test.php

You need to create this file in the /var/www/ directory on your Ubuntu machine.

In this file include the following:

<?php phpinfo(); ?>

Open up a web browser of your choice and browse to:

http://localhost/test.php or  http://IPOFYOURSERVER/test.php

Your web browser should look similar to the image below.

draalin-installing-lamp-2

 

You can also test out the PHP in action with an html page if you would like.

This can be done by, for our example creating a file called test2.php

Put this file in the same directory as test.php which was in the /var/www/ directory on your Ubuntu machine.

In this file include the following:

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>

Open up a web browser of your choice and browse to:

http://localhost/test2.php or  http://IPOFYOURSERVER/test2.php

Your web browser should look similar to the image below.

draalin-installing-lamp-3

 

3. Finally lets test out MySQL, type in the following.

mysqladmin -u root -p status

If everything is working correctly, you will end up with something like this below.

draalin-installing-lamp-MySQL-3

Added gallery for support below.

 

Installing LAMP was easy! You are now done.

If you require any other help please check out our forums here.

For more details regarding LAMP from Ubuntu go here.

About Tyler Bailey

Tyler Bailey is a university student who owns and runs draalin.com. Follow me on
  • DaveB

    Neat, that was pretty easy.

    Do you have anything similar for phpMyAdmin?

    Thanks

    • http://draalin.com draalin

      Not as of right now, but I plan on writing one up soon.

  • carl lindberg

    I think the easiest way to install a LAMP Linux Apache MySQL PHP

    with phpMyAdmin in Ubuntu is to open the terminal and run

    sudo aptitude install phpmyadmin

  • Pingback: Starting a Website from Scratch | Zahid Khawaja