Thursday, January 7, 2010

Installing LAMP in Ubuntu.

Salam guys...

I think this is my first technical post in my blog. So, I'll focus to post any basic knowledge (since I'm also a newbie in this stuff). Anyway, this post I'll mention about LAMP.

By definition, LAMP (Linux, Apache, MySQL and PHP) is an open source Web development platform that uses Linux as operating system, Apache as the Web server, MySQL as the relational database management system and PHP as the object-oriented scripting language. I've installed LAMP in my Ubuntu 9.10, Karmic Koala and I hope that I could share something that beneficial to you guys.


Install LAMP

In Ubuntu, you would find that it is very easy to install LAMP server on an existing operating system.

Open up the Terminal (Applications > Accessories > Terminal)


Type this following command;

sudo apt-get install lamp-server^

The apt package manager will show what packages that needed to be

installed. Just hit key to confirm the installation.


A menu will be prompted to set root's passwords in the MySQL database. Just

enter the password you want. You will have to enter it twice to confirm the

password. After you enter it, the installation will resume until it finish.

Done! It's simple. Next, we have to test the Apache on our server.


Test Apache


Open a web browser and enter the address http://localhost/. You should get a web page that says 'It Works!'


Testing PHP


Since the Apache is already working, now we need to test the PHP installation. We'll have to create a php file in the /var/www directory called testing.php.


In the terminal, type;

gksudo gedit /var/www/testing.php

A text file will be created and prompted in your desktop. Type the following

line, save it and exit.


Restart the Apache server by simply type the command below;

sudo /etc/init.d/apache2 restart


Once the Apache has already restart, go back to the web browser and enter the address http://localhost/testing.php/. A page contains full version information of your php installation will be displayed.


Configure MySQL


I've installed my LAMP as a web development environment, so I want to bind the MySQL database to the localhost IP address. By default, it should be 127.0.0.1.


To verify it, enter the following command in the terminal;

cat /etc/hosts | grep localhost


If you want to verify that the correct bind address is set up in the my.cnf file, type this command;

cat /etc/mysql/my.cnf | grep bind-address

Then you'll see the line that shows bind-address = 127.0.0.1. If it doesn't match, you have to edit it in the my.cnf file.


Install phpMyAdmin


Installing phpMyAdmin is optional, but it could help much easier to manage your MySQL database.


In the Terminal, enter the following command;

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


The installation will prompt you a menu to select a web server for automatic

configuration. Use the space bar on your keyboard to select apache2 and then

hit ENTER key.


Another menu will appear to ask you if you want to configure a new database

called dbconfig-common. Since you are fresh in this installation, just select Yes

and hit ENTER key.


You'll be prompted next to enter the MySQL root password. Enter the MySQL

root password that you created earlier, select Ok and hit ENTER key.


Then, you'll be ask to enter MySQL application password for phpmyadmin. I've

used the same password that I used for the root MySQL password. If you

enter your own password, a password confirmation screen will come up and

confirm your password.


The phpMyAdmin installation has been completed. To test your phpMyAdmin, you may enter it by opening your web browser and enter the address http://localhost/phpmyadmin. Then, you can log in with the username root and the root password that you created earlier.


Done! You may enjoy building your websites. You may put all the files in the /var/www.

Good luck! :)



3 comments:

Anonymous said...

ataupon "sudo tasksel install lamp-server"
:)

♥ bayataya ♥ said...

wah!
=P

Johan Effendi Bin Abdul Razak said...

Sala: Aku dah try dah command tu mula2, tapi tak berapa jadi.. hehehe.

B: Nanti abg ajar... :P