Install LAMP Server On Ubuntu

August 4th, 2012 by Laeeq | 1 comment

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:

  1. 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:

  1. 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:

  1. 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:

  1. 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:

  1. 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:

  1. <?php
  2. echo “My Test PHP”;
  3. ?>

Step 3. Save and close the file.

Step 4. Now open your web browser and type the following into the web address. it

  1. 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:

  1. sudo apt-get install mysql-server

Step 2. Now type the following line into Terminal:

  1. mysql -u root

Now copy/paste the Following and set the password:

  1. 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:

  1. 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:

  1. 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:

  1. ;extension=mysql.so

To look like this:

  1. extension=mysql.so

Now just restart Apache and you are all set!

  1. 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.

You can subscribe to PHPZAG.COM posts by Email

 

Related Topics:

 

 

  1. post
    November 1st, 2012 at 04:32 | #1

    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.

  1. No trackbacks yet.