Sunday, November 15, 2009

LAMP server on Ubuntu

Share Orkut

If you want to have a LAMP server on your Ubuntu machine, but found if difficult to install the different components seperately, the geeks (developers) at Ubuntu have literally made it as good as spoon-feed. For the un-initiated, LAMP is a software bundle for Linux, consisting of Apache HTTP server, MySQL (database component), PHP (for scripting).

The result of their efforts is the following command,

sudo apt-get install lamp-server^

Note: The carrot is not a typo-error, its part of the command. It refers to the 'Tasksel packages' for different tasks. If you need to see the complete list type "sudo tasksel" in the console.

Follow the onscreen instructions, you will be prompted to confirm all the packages, reply with 'YES'. While the installation is halfway, you will be prompted to chose a password for the root user on the MySQL database. Enter your password and confirm it.

Thats it, the install is done; now for the configuration part.

1] Apache2: Open "http://localhost/" in a browser window, if you see a page with "It Works" written on it; then you apache2 installation has succeeded.

Open a terminal window, and paste the following into it, to open up apache2.conf;
sudo gedit /etc/apache2/apache2.conf

add an entry to the end of the file; ServerName your-domain.com (you will have to replace your-domain.com)

2] PHP: Open a console, and type
sudo gedit /var/www/phptest.php

here, enter the following code in the gedit document,

<? php phpinfo(); ?>


restart apache2 with the following command
sudo /etc/init.d/apache2 restart


Now open your browser to "http://localhost/phptest.php"; if your PHP install was succesful, this page will list out the details of the PHP installation.

3] MySQL
Open the MySQL configuration,
sudo gedit /etc/mysql/my.cnf


Make sure the following setting is proper.
bind-address = 127.0.0.1


(This is an optional step)
Installing phpMyAdmin
sudo apt-get install libapache2-mod-auth-mysql phpmyadmin

Follow the onscreen instructions to complete the install, you can access it at "http://localhost/phpmyadmin/"

Finally restart the apache2 server;
sudo /etc/init.d/apache2 restart


There you go, your machine is up and running

1 comments:

Anonymous said...

Useful tutorial

Post a Comment

Write your comment here