Install LAMP Server On Ubuntu
In this post I will explain how to install a LAMP(Linux,Apache,Mysql,PHP) system.
First we will install Apache:
1. Open up the Terminal (Applications > Accessories > Terminal).
2. Copy/Paste the following line of code into Terminal and then press enter:
- sudo apt-get install apache2
3. The Terminal will then ask you for your password, type it and then press enter.
Now we will test Apache installation
To make sure that everything installed correctly we will now test Apache to ensure it is working properly.
1. Open up any web browser and then enter the following into the web address:
- http://localhost/
You should see a folder entitled apache2-default/. Open it and you will see a message saying ”It works!” , congrats to you!
Now we will Install PHP
Here we will install PHP 5.
Step 1. Again open up the Terminal (Applications > Accessories > Terminal).
Step 2. Copy/Paste the following line into Terminal and press enter:
- sudo apt-get install php5 libapache2-mod-php5
Step 3. In order for PHP to work and be compatible with Apache we must restart it. Type the following code in Terminal to do this:
- sudo /etc/init.d/apache2 restart
Now we will Test PHP Installation
To check that there are no issues with PHP installation.
Step 1. In the terminal copy/paste the following line:
- sudo gedit /var/www/myphptest.php
This will open up a file called myphptest.php.
Step 2. Copy/Paste this line into the myphptest.php file:
- <?php
- echo “My Test PHP”;
- ?>
Step 3. Save and close the file.
Step 4. Now open your web browser and type the following into the web address. it
- http://localhost/myphptest.php
The result will be: My Test PHP
Now We will Install MySQL
Here we will finish mysql installation step by stesp
Step 1. Again open up the Terminal and then copy/paste below line:
- sudo apt-get install mysql-server
Step 2. Now type the following line into Terminal:
- mysql -u root
Now copy/paste the Following and set the password:
- mysql> SET PASSWORD FOR ‘root’@‘localhost’ = PASSWORD(‘yourpassword’);
(You can change password of your choice.)
Step 3. Now We will install a program called phpMyAdmin which is an easy tool to edit your databases. Copy/paste the following line into Terminal:
- sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
After MYSQL/phpMyAdmin installatio our next task is to get PHP to work with MySQL. To do this we will need to open a file entitled php.ini. To open it type the following:
- gksudo gedit /etc/php5/apache2/php.ini
Now we are going to have to uncomment the following line by taking out the semicolon (;).
Change this line:
- ;extension=mysql.so
To look like this:
- extension=mysql.so
Now just restart Apache and you are all set!
- sudo /etc/init.d/apache2 restart
You have now installed a LAMP server on Ubuntu! You are now ready to manage web projects with server side scripting and MySQL database access.
Follow @phpzag

I’m generally to blogging and i genuinely appreciate your website content. This content material has actually peaks my interest. I am going to bookmark your internet site and keep checking choosing info.