Tech

Guides
 

Quickly install a LAMP server on Ubuntu

By Jack Wallen, Special to ZDNet Asia
Monday, December 29, 2008 10:50 AM
Here are some quick and easy steps to installing a LAMP server on a running Ubuntu machine.

I can't tell you how many times I have been asked what is the fastest, easiest way to install a LAMP (Linux Apache, MySQL, PHP) server on Ubuntu. Well, I guess it's time I just post it here for everyone to enjoy.

I am going to assume that this server does not have any of the components pre-installed. I am also going to assume you have sudo permission for the server. So starting with a blank slate we will first install Apache. To install Apache you will need to issue (from a terminal) the command:

sudo apt-get install apache2

Once this is installed you want to make sure Apache is up and running, so fire up your browser and point it to http://localhost (or you can use the servers' IP address). If you get the message "It Works!" you are good to go.

With Apache installed, let's move on. The next step should be installing PHP. To get php installed so that it will have everything it needs to integrate with Apache issue the command:

sudo apt-get install php5 libapache2-mod-php5

Before Apache can see that php is installed you will have to restart Apache like so:

sudo /etc/init.d/apache2 restart

Time to test to make sure php is working. Create a file within /var/www/testphp.php with the following contents:

< ?php phpinfo(); ?>

save that file in /var/www/ and then point your browser to that file. If all is well you will see the text, "Test PHP Page". If you see that, you can move to to…

The next step: MySQL.

To install the necessary tools, issue the command sudo apt-get install mysql-server. Once the system is installed it gets just a bit tricky. You have to first set a password for mysql. To do this, run the first command in order to get to the mysql prompt and the second to set the password:

 mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('YOURPASSWORD');

Where YOURPASSWORD is the actual password you want to use for the root user.

You're done. You now have a basic LAMP installation. Of course I would suggest taking this further by installing phpmyadmin in order to make creating MySQL databases much easier. But other than that, you are ready to install applications that require the LAMP configuration.

Jack Wallen was a key player in the introduction of Linux to the original Techrepublic. Beginning with Red Hat 4.2 and a mighty soap box, Jack had found his escape from Windows. It was around Red Hat 6.0 that Jack landed in the hallowed halls of Techrepublic.



WORTHWHILE?

0

0 votes
Blog

Talkback 6 comments

alternative method with synaptic and drupal
there is an alternative method of setting up a lamp server with the drupal content mgmt system. i am using ubuntu 8.04 with a broadband internet connection

1. click on menu system > administration > synaptic package manager
2. from the synaptic package manager, click on the search button
3. from the find dialog button, search for drupal and look in name
4. from the resulting package list, right-click drupal5 and select mark for installation
5. when synaptic automatically prompt to install the dependencies (which includes apache, mysql and php) click on the mark button
6. from the synaptic package manager, click on the apply button
7. synaptic will then download and install apache, mysql, php and drupal

you should also read up on securing ubuntu and configuring drupal
Posted by Raja Iskandar Shah on Monday, December 29 2008 02:20 PM

alternative to above
Why not just download xampp.. i use this for my wamp applications but they also have a lamp version.. you can check it out here.. www.apachefriends.org.... they have the downloadable installer for php/mysql plus some other programs...

The site also offers instructions on how to install..
Posted by Alphonse Tan on Monday, December 29 2008 03:04 PM

AGREE with alernative in using xampp
xampp gives you good instructions, and really makes it easy. here is the funny part of all these help articles. rarely, they tell you how to start and stop the servers. xampp makes it very simple and even has commands you need. it makes it really easy, with the information at your fingertips, and i tried them all.
Posted by Trent Black on Tuesday, December 30 2008 04:01 AM

any different?
I am new in Linux and Ubuntu. I wonder if there is any different between the installation described in this article and XAMMP.
Posted by ongray on Tuesday, December 30 2008 09:42 AM

alternative methods
alternative methods when using ubuntu linux :
1. install from command line if you want it lean and mean
2. install from synaptic if you want the official ubuntu repositories
3. download and install if you want the latest version
4. download source, compile and install if you have a custom machine

i prefer to synaptic which will resolve all dependencies and updates

xampp is good for developers as it includes additional tools
Posted by Raja Iskandar Shah on Tuesday, December 30 2008 06:43 PM

Xampp works great in Linux & Windows
Thanks Alphonse for XAMPP. I have installed it in Suse and Windows and it works so fine.
In Suse we just have to take care of unzip and place the unzipped folder structure in /opt/xampp and in Windows under D:\Xampp .

Thanks again.
Posted by Rahul Sinha on Monday, January 12 2009 02:20 PM


Guest user

Guest user

Level: 
Joined: —
Already a member? Log in »



 

Loading...

Whitepapers/Case Studies

Downloads

Open Source News



Tech Jobs Now!

Tags

  1. canada
  2. e - mail
  3. fedora project
  4. gnome
  5. linux
  6. linux distribution
  7. mandriva
  8. mysql
  9. open source
  10. operating systems
  11. password
  12. red hat inc.
  13. repository
  14. security
  15. server
  16. ssh
  17. tool
  18. ubuntu
  19. vincent danen
  20. web