In this multi-part article, I’m going to be showing you how to install the popular LAMP stack - that’s Linux, Apache, the MySQL database system and PHP (in this example, although you can have Perl, Python etc. instead) for running your own website or web development server.
The LAMP stack is a very popular setup and many websites run on it (including FOSSwire!). Best of all, all four of the tools in the stack are free and open source and really easy to get started with. For this tutorial, I’m going to be showing you how to install LAMP on Ubuntu 7.04 Feisty Fawn, but the process is very similar for other Linux distributions too. By the way, if you have a Windows machine that you want to do this on, check out this tutorial on our sister site GizBuzz instead for a nice easy WAMP setup.
Step One - get the software
All the stuff you need is pre-loaded into Ubuntu’s software repositories, and it’s really simple to install everything you need. If you’re doing a new install, you may want to take a look at the server edition of Ubuntu as it allows for a pre-configured profile that you can pick at install time.
For this tutorial, I’m going to assume you’ve already got your Ubuntu desktop up and running, though.
To get stuff installed, you need to install the following packages:
- apache2
- php5-mysql
- libapache2-mod-php5
- mysql-server
The most universal and quickest way to do this is to pop open a terminal and type in the following command:
$ sudo apt-get install apache2 php5-mysql libapache2-mod-php5 mysql-server
Step Two - do some minimal configuration
Let that download and install. Once that’s all finished, we need to do just a little bit of configuration before we can start using our new LAMP setup and that is to set a root password for the MySQL database server (without this step, you will have an insecure setup).
It’s pretty simple to do:
$ mysqladmin -u root password yournewrootpassword
That will set your MySQL root password, which you can now use to log in to your MySQL server.
Step Three - start using it!
That’s pretty much all the configuration you need to do, so you can now grab any web applications you want and install them. Don’t use the root MySQL user for your databases though if you are working in an environment where you need things to be secure. Set up a user and database for each application you install (you can use something like PHPMyAdmin for this).
In the next part of this tutorial, I’ll be looking at some awesome tweaks you can make to your LAMP setup and how to easily install some of the most popular web applications.
Tips and tricks
To start and stop the servers independently of rebooting (for example after changing configuration files, you can use these commands):
Apache and PHP
$ sudo /etc/init.d/apache2 restart
Replace ‘restart’ with either ’start’ or ’stop’, as needed.
MySQL
$ sudo /etc/init.d/mysql restart
Update: Part 2 of the tutorial is now online, with tweaks, hacks and more configuration!



FOSSwire » Installing and configuring LAMP on Ubuntu - Part 2 wrote:
[…] Posts Installing and configuring LAMP on Ubuntu - Part 2Welcome back! In Part 1 of this tutorial, I looked at installing the tools you need to get your own web server up and […]
# Posted on 01-Jun-07 at 10:40 am
FOSSwire » eyeOS - the open source web desktop wrote:
[…] Posts Installing and configuring LAMP on Ubuntu - Part 2Welcome back! In Part 1 of this tutorial, I looked at installing the tools you need to get your own web server up and […]
# Posted on 08-Jun-07 at 11:43 am
Shahryar Ghazi wrote:
good work!
# Posted on 27-Jun-07 at 12:59 pm
FOSSwire » Drupalicious wrote:
[…] up and mess around with your…Installing and configuring LAMP on Ubuntu - Part 2Welcome back! In Part 1 of this tutorial, I looked at installing the tools you need to get your own web server up and […]
# Posted on 03-Jul-07 at 3:03 pm
Building a Linux Server and LAMP on Ubuntu - Intelligentedu.com Free Computer Training Blogs wrote:
[…] WebminShare some more and Cleaning upOpen another Port and sFTP/SCPDe-bling-anizeWrapping Up2) Installing and configuring LAMP on Ubuntu - Part 1In this multi-part article, I’m going to be showing you how to install the popular LAMP stack […]
# Posted on 06-Aug-07 at 7:50 pm
Sam wrote:
Good guide, one can also add the Unbuntu desktop GUI afterwards by following this guide.
http://www.zaphu.com/v1/2007/08/07/ubuntu-lamp-server-setup-guide-with-desktop-gui/
Hope that is useful.
-Sam
# Posted on 16-Aug-07 at 8:34 pm
/usr/bin/.website » LAMP failure wrote:
[…] week, and as I have done with every other reinstall; I have followed the excellent tutorial (parts 1 and 2) written by Peter Upfold. I have always had great success in getting it to run, and his is […]
# Posted on 30-Sep-07 at 8:26 pm
Josh wrote:
Hmm.. I just used this tutorial (reinstalled my OS, so i needed to reinstall my LAMP) .. and for some reason nothing is working right. Apache _is_ running, but for some reason php5 wasnt installed, my mysql is refusing to accept my root password, and when i visit http://localhost it asks me if i want to download a no-named PHTML file. Any help or suggestions would be nice.
# Posted on 30-Sep-07 at 8:49 pm
/usr/bin/.website » LAMP back online wrote:
[…] That’s going to go in and install every package needed to run a LAMP server. There is also an excellent tutorial on how to setup the LAMP and configure it on FOSSwire.com (1)(2). […]
# Posted on 06-Oct-07 at 6:52 am
/usr/bin/.website » LAMP failure wrote:
[…] past week, and as I have done with every other reinstall; I followed the excellent tutorial (parts 1 and 2) written by Peter Upfold. I have always had great success in getting it to run, and his is […]
# Posted on 18-Oct-07 at 10:29 pm
Order of the Bath » Blog Archive » Installing LAMP on Ubuntu 7.10 Desktop wrote:
[…] The references used to achieve (and write) this were LAMP Installation On Ubuntu, Installing LAMP on Ubuntu 7.10 and Installing and configuring LAMP on Ubuntu. […]
# Posted on 02-May-08 at 1:23 pm