HowTo: Installing LAMP server in your Ubuntu Desktop

Since I install Ubuntu 7.10 (Gutsy Gibbon) Desktop Edition in my desktop, I’ve been using it for all my projects. As an aspiring web developer I should have LAMP installed in my desktop. And I am not the only one like this. Many other Ubuntu users wants to install LAMP to their machine. And now I will guide you through installing it. I divided this guide in 3 simple and easy steps with the help of the terminal.

The steps will be:

Installing Apache

Let’s start:
First open your terminal (Application >> Accessories >> Terminal)

Now, we will install apache using the codes below

sudo apt-get install apache2

Note: your www folder directory will be /var/www/
If everything is OK you should see an ordinary HTML page when you type http://localhost in your browser

Installing PHP

After installing apache, we should now install PHP in our webserver. The code we will use will be

sudo apt-get install php5 libapache2-mod-php5

Now you will have to test if it is working. You can use the text editor or you can use this code

sudo gedit /var/www/test.php

and write inside the file


<?php
for ($x = 1; $x <= 100; $x++)
{
if ($x == 100)
{
echo "hello world";
}
}
?>

I made it long so we can assure that the PHP is working correctly.

Installing MySQL

We are almost there. This is the last whole step, installing MySQL.

sudo apt-get install mysql-server

While the installation is running you will be given a input box to enter your password. You should enter a password so you won’t have to bother changing it after the installation.
But if you want to change your password after installation then this will be the code you should use:

mysql> SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(’xxxxxx’);

If you want to try if the MySQL is working then use this code:

mysql -uroot -pxxx

Optional

Many of us like to have phpMyAdmin installed in their webserver so I included some extra so you can use it with MySQL

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

and then we will have to add a line in apache2.conf. You can use this code:

sudo gedit /etc/apache2/apache2.conf

and add the following code

Include /etc/phpmyadmin/apache.conf

Now we’re finished. The only last thing we should do is to start Apache.

sudo /etc/init.d/apache2 start

Some extra points you should remember are the permissions. You should remember each of them. I will give you 3 most common permissions, 777, 775, 755. This are called chmods. Samples of them are in here.

sudo chmod [numerical value] /path/to/file.extenstion

You can change the permission by using the code above. You can also use it for any folder/directory. But you should change permission of every one of the folders so your site won’t have any “Forbidden” errors.

As for the last option I can think of is by enabling GD library. GD library is needed so you can use some functions like imagecreate(). You should install the GD library by using this code:

sudo apt-get install php5-gd

You can also install it by using the Synaptic Package Manager

No related posts.

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

No comments yet.

Leave a comment

(required)

(required)


ss_blog_claim=943397671420990dde83214c28892d78