How to install LAMP in Ubuntu (linux)

LAMP stands for Linux, Apache, MySQL and PHP/Python. Installing and configuring LAMP is not a very complicated thing in Ubuntu, its just a matter of few lines of commands via the command line. This post will show you how to install PHP5, Apache2, MySQL and phpMyAdmin in Ubuntu.

Installing Apache

1. Open the terminal and type the following command.



sudo apt-get install apache2

2. Type the password when asked and press enter key.
3. To test if apache is installed in your system or not. Open the browser and type localhost. If you see a message saying "it works" then its installed.

Installing PHP5

1. Open the terminal and type the following command.

sudo apt-get install php5 libapache2-mod-php5

2. Restart apache by typing the following command.

sudo /etc/init.d/apache2 restart

3. Now test if PHP is installed in your system or not. Type the following command in the terminal to edit a PHP file.

sudo gedit /var/www/myfirstphp.php

4. Type the following code in the editor and save it.

<?php echo "hello world";?>

5. Open the browser and type the following URL.

http://localhost/myfirstphp.php

6. If it displays hello world then it works.

Installing MySQL

1. Open the terminal and type the following command.

sudo apt-get install mysql-server

2. It will ask you for the MySQL password. Enter and remember the password. You can change the password by typing the following command.

mysql -u root

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');

Installing phpMyAdmin

1. Type the following command in the terminal to instal phpMyAdmin.

sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

2. Now we need to configure php.ini file to make PHP work with mysql. So type the following command.

gksudo gedit /etc/php5/apache2/php.ini

3. Search for ';extension=mysql.so' and remove the semicolon(;) which is in the beginning of the line. It must look like this.

extension=msql.so

4. Save the file and restart Apache by typing the following command and you are done.

sudo /etc/init.d/apache2 restart

Comments

Popular posts from this blog

Getting latitude, longitude, timezone using ip address.