Undetectable Humanizer: Lifetime Subscription
Transform AI-Generated Text into Human-Like, High-Ranking Content & Bypass Even the Most Sophisticated AI Detectors
Get 95% Deal

How to: Install a LAMP server

Jack Wallen
Jul 23, 2009
Updated • Nov 30, 2012
Network
|
21

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:

  • Linux
  • Apache
  • MySQL
  • P (can mean PHP or PERL - depends upon your needs)

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.

Hardware needed

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.

Install prerequisite

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.

Apache

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.

PHP

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.

MySQL

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:

/etc/init.d/mysql start

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:

sudo tasksel

You will need to select LAMP from the list and you will eventually be prompted for a MySQL password. That's it.

Final thoughts

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.

Advertisement

Previous Post: «
Next Post: «

Comments

  1. Carlos said on September 19, 2017 at 2:38 am
    Reply

    Hello, thank you very much, we are here in Brazil and we do not have much information like this, thank you very much for sharing you solved my problems

  2. Maicon Rissi said on January 28, 2013 at 6:08 am
    Reply

    Very good tutorial!

    Congratulations!

    ;-)

  3. John Li said on September 27, 2012 at 4:06 am
    Reply

    Jack, great tutorial. Just FYI, I think the correct path is /var/www/html/ for the test.php also it didn’t seem to work for me with the contents of ” “. But I am using Centos 6.2 apache 2.2.4.

    Chris, if you are using GUI then it would be: File System /var/www/html/

  4. Ganhar Dinheiro said on February 20, 2012 at 10:38 pm
    Reply

    very good this tutorial will help me a lot when I’m doing this installation

    Thanks

  5. Ganhar Massa Muscular said on October 7, 2011 at 11:22 pm
    Reply

    Very good this tutorial! It was very useful for me! Thanks for publishing!

  6. tenis oakley masculino said on March 21, 2011 at 5:42 pm
    Reply

    yes, After reading you site, Your site is very useful for me .I bookmarked your site.

  7. Ravi said on February 18, 2011 at 8:29 am
    Reply

    Thanks a lot

  8. Forever Brasil said on January 29, 2011 at 3:31 am
    Reply

    Thanks! Very good post!

  9. Jazida.com said on January 12, 2011 at 7:40 am
    Reply

    Thnaks!

  10. Ganhar Dinheiro na Internet said on May 2, 2010 at 6:29 pm
    Reply

    Thank you very much! Your post was very useful to my hear in Brazil!

    Dani Edson

  11. Chris said on March 7, 2010 at 9:47 pm
    Reply

    I can’t save files into the /var/www directory. I looked at the properties of the www folder and then into permissions and it says that I do not have any permissions as I am not the owner. Any idea’s what I can do?

  12. Diego said on July 24, 2009 at 7:32 pm
    Reply

    Excelente tutorial.
    I have one cuestion, how I install PHPMyAdmin?
    Thanks!

  13. Jack Wallen said on July 24, 2009 at 5:01 pm
    Reply

    Brian: Sorry about that. I blame spell check. ;-)

  14. brian said on July 24, 2009 at 8:26 am
    Reply

    dude….it’s PERL, not “pearl”

    1. T-Bone said on December 19, 2011 at 5:16 pm
      Reply

      Brian,
      at least appreciate the effort… idiot..

  15. Nick said on July 24, 2009 at 8:02 am
    Reply

    Thank you. Your post came just right on time!

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.