Setting up a LAMP (Linux, Apache, MySQL, PHP) Stack in Ubuntu

Today I’m going to show you how to install and setup a LAMP stack. LAMP Stands for Linux, Apache, MySQL and PHP.

This is a very powerful software stack used for creating websites and web APIS (Application Programming interface)

So let’s get started. If you are reading this post then I would like you have the Linux part installed, you can view my tutorial here

The easiest to install it is to use tasksel or you can install them individually.

sudo tassel

 

You should get a screen that looks like this.

Screen Shot 2015-08-05 at 22.13.25

 

As you can see there are a lot of options you can choose from but we only need one of them.

Select LAMP Server and let it do its thing and your good to go. :)

When it gets around to installing MySQL it will ask you to create a root password, don’t forget this password otherwise it will mean downtime for the server which no one wants.

Screen Shot 2015-08-05 at 22.16.56

 

It will ask you to repeat the password .

Now just sit back and let it finish and you will have a LAMP server :)

If you don't want to use tasksel

This is how to would install the packages individually, we need to install Apache, MySQL Server, PHP 5.x

To install Apache.

sudo apt-get install apache2

To install MySQL server.

sudo apt-get install mysql-server

 

When you install MySQL server it will ask your for a password as it did above.

 

To install PHP.

sudo apt-get install php5

 

Now to get your servers IP address you can do this by

ifconfig

 

You should get something like this

eth0         Link encap:Ethernet HWaddr 08:00:27:08:71:26
             inet addr:192.168.0.13 Bcast:192.168.0.255 Mask:255.255.255.0
             inet6 addr: fe80::a00:27ff:fe08:7126/64 Scope:Link
             inet6 addr: fd93:225a:6a91:0:b80c:21cc:138e:e0b9/64 Scope:Global
             inet6 addr: fd93:225a:6a91:0:a00:27ff:fe08:7126/64 Scope:Global
             UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
             RX packets:96 errors:0 dropped:0 overruns:0 frame:0
             TX packets:97 errors:0 dropped:0 overruns:0 carrier:0
             collisions:0 txqueuelen:1000
             RX bytes:15224 (15.2 KB) TX bytes:12579 (12.5 KB)

lo           Link encap:Local Loopback
             inet addr:127.0.0.1 Mask:255.0.0.0
             inet6 addr: ::1/128 Scope:Host
             UP LOOPBACK RUNNING MTU:65536 Metric:1
             RX packets:0 errors:0 dropped:0 overruns:0 frame:0
             TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
             collisions:0 txqueuelen:0
             RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

Create your first PHP script.

Now we can create a php script to test the configuration. If you create a file in /var/www/ called info.php

sudo nano /var/www/info.php

 

<?php phpinfo();?>

 

There you have it, you should get something similar to this2