28 August, 2009

Setting up LAMP (Linux Apache MySQL PHP) on Ubuntu 9.04 - Adding it to a Desktop installation



OK, well I have just setup a new computer that will be acting as my server from now on. This time setting it up was slightly different though, unlike in the past where I have just used the Ubuntu Server edition I have this time chosen to used the Desktop edition and then add the server components to it. The reason that I am doing this is that the computer I am using will also be used as the terminal in my bedroom for browsing the internet and doing word processing basically so I don't have to use my power hogging noisy machine as much.

So after installing Ubuntu desktop edition using the alternate CD so I could have software raid like all good servers should(tutorial soon) I decided to install and setup LAMP(Linux Apache Mysql and PHP) below is a guide showing how to set this up, it is basic and is designed to be a development environment not a production server, there are lots of things that can be done to make it better but are outside the scope of this article. Well down to business:

This is actually a very simple process firstly you need to install apache using this command:

sudo apt-get install apache2

You can check that apache is working by loading up a web browser and navigating to http://localhost/

At the moment whenever you restart apache you will get an error, it's not really a problem but to stop it happening and because its the thing to do we will fix it, to do that enter this command:

sudo gedit /etc/apache2/httpd.conf

Add the following line to the file:

ServerName localhost

Save the file and restart apache:

sudo /etc/init.d/apache2 restart

Well that is apache installed 2 down 2 to go...

Next we are going to install PHP, to do that use the next command:

sudo apt-get install php5

Now that the PHP has being installed Apache needs to be reset:

sudo /etc/init.d/apache2 restart

OK thats PHP installed, isn't Ubuntu easy....

Now we are going to install MySQL, to do that run the following commands:

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


During the install of MySQL you will be asked to setup a root password, just follow the onscreen instructions.

Now you have to edit php.ini to enable the extension:

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

add this line to the file:

extension=mysql.so

Now that that is installed we are going to install phpMyAdmin

sudo apt-get install phpmyadmin

Restart Apache again:

sudo /etc/init.d/apache2 restart

Now test phpmyadmin is working by visiting:

http://localhost/phpmyadmin/

The username and password is taken from the MySql install, meaning the User is root and the password is whatever you entered.

Well that is a basic LAMP setup perfect for development work, the website is located in /var/www


------------------------------------------
NOTE: These articles are tutorials/general ramblings. I do not except responsibility for anything that goes wrong, be it a broken HDD, an entire computer or if you chop off your arms, follow anything I say on this site at your own risk.
------------------------------------------

Comments



Leave a comment

Name:


URL:(optional)


Protection Number (Please insert in box below):4642


Comment:


This website was designed and implemented by myself, all opinions and views expressed are my own unless otherwise specified. Excluding the images contained within the header and any specified elsewhere on the site images are my own.

Copyright Rob Ward
2009 - 2010