If you've read enough of my Ghacks tutorials you have most likely come across mention of a LAMP server. If you are not sure what a LAMP server is:
LAMP servers are very popular, cheap, effective, flexible, and reliable servers. But how are they installed? Actually, it's not that hard. In this tutorial I am going to show you how to install a LAMP in two different ways: From the command line (using separate tools) and using the tasksel tool.
Fortunately a LAMP server can be installed on lower-end hardware and still serve as a fairly efficient server. Naturally if you are going to be using your LAMP server for high traffic, you will want to select your hardware wisely.
Before you begin the installation of your server you will need to have your operating system installed. This is the "L" of LAMP. So find your favorite Linux distribution and install the operating system. For the purposes of this installation I am going to be installing on a Ubuntu 9.04 server installation. This will be a console only server (no GUI desktop) which is fine because the installation is done via command line only.
Once you have your operating system installed you are ready to install your server.
This is the easiest portion to install. Either log in to your console or open up a terminal window (if you are working from a GUI desktop) and enter the following command:
sudo apt-get install apache2
You will have to enter your sudo user password for this installation to continue. Once this installation is complete check it by pointing a browser to that server IP address. You should instantly know if Apache is up and running.
For the purposes of this article we will assume the "P" stands for PHP. To install PHP (and all of its requirements) issue the command:
sudo apt-get install php5 libapache2-mod-php5
Once this installation is complete restart Apache with the command:
sudo /etc/init.d/apache2 restart
Let's make sure this portion works properly. To test this create a file in the Apache document root (for this install it will be /var/www) called test.php. The contents of this file will be:
< ?php phpinfo(); ?>
Save that file and then point your browser to http://IP_ADDRESS/test.php
Where IP_ADDRESS is the actual IP address of your server.
You should see "Test PHP Page" written on your browsers page. If so, you're good to go.
Now to install MySQL. To do this issue the command:
sudo apt-get install mysql-server
Once this is done you then need to set a password for MySQL. To do this issue the command:
mysql -u root
which will put you in the MySQL prompt. From this prompt (which looks like mysql> ) enter the command:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('YOURPASSWORD');
Where YOURPASSWORD is the password you want to use for the mysql user.
Now start your MySQL server with the command:
That's it. Your LAMP server is up and running.
The quick version
You can actually install a full-on LAMP server on a (Ubuntu server install) with a single command:
You will need to select LAMP from the list and you will eventually be prompted for a MySQL password. That's it.
Getting a powerful, flexible web server up and running will take you less time and effort than you think. LAMP servers are an outstanding choice for your web servers' needs.
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.