How to install LAMP in Ubuntu 14.04
I wanted to setup a LAMP stack on my Ubuntu. I was kind of hopin that it would be just a walk in the park as what i did with windows WAMP. I tried googling the steps and did find some nice tutorials. I will walk you through with my installation and hope i’d be successfull with this exercise.
So lets get it on
Step 1 : — Install Apache
First though we need to update our system
sudo apt-get update
Then we can install apache
sudo apt-get install apache2
After the installation you can open your browser and in the address bar just type
You will see the Apache 2 Ubuntu Default Page
And it says “It works!” hehehe, you can take a deep breath for now
Note : After you installed apache2 it will create the document root directory at /var/www/html
Step 2 : Install Mysql
sudo apt-get install mysql-server php-mysql
Notice that we added “php5-mysql” so that php5 and mysql can properly communicate with each other (“some helper tools”).
During installation it will prompt you to enter a root security password for the root access of your mysql database.
After the installation you can check if mysql is running by typing:
mysql -u root -p
Enter password: "here you type your password"
then you should see the server verion of your mysql and other stuff. Just type “exit” to go back to command prompt.
We need to execute and tell MYSQL to create its database directory structure where it will store its information.
Then secure your mysql installation especially in actual production mode
You will be ask security questions. I answered “Y” for all of its questions hehehe just bring it on.
Step 3 : Install PHP
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
After installation you can start with a project by creating an html file at “/var/www/html”. By default apache would give priority to index.html file but we all want to give hail to index.php. So to do that we edit dir.conf
sudo nano /etc/apache2/mods-enabled/dir.conf
It should return something like this
DirectoryIndex index.html index.cgi index.php index.pl index.xhtm$
So change the order, put index.php first on the list like this
DirectoryIndex index.php index.html index.cgi index.pl index.xhtm$
Then save. Ctrl – X then “Y”
It is important to notice that we change some behavior of apache2 to identify .php prior to .html and others, so we need to restart the service for the change to take effect.
sudo service apache2 restart
Then install php modules ( check for available modules )
apt -cache search php5-
Next step is testing the PHP
create a file named test.php in “/var/www/html” and inside test.php write
Then open the browser ahd in the address bar type
You should see PHP Version in your screen and its configuration and lots of information.
Yes we did it! we did it! Time to coooooooooooooooooode! Good day everyone!