Pin Me

Easy LAMP (Linux Apache MySQL PHP) Server Installation

written by: jlwallen•edited by: Michael Dougherty•updated: 12/26/2008

The LAMP (Linux Apache MySQL PHP) server is one of the most popular servers in the world. There are many reasons for its popularity (it's free and reliable), but one reason should stand out above all other. It's simple to install. This article will outline the steps to install a LAMP server.

  • slide 1 of 5

    Such Power

    Such a powerful server shouldn't be so simple to install. Considering how much LAMP, might be a real challenge. Well it's not. In this article you will find out how simple this server is to install. I'm assuming you have your distro up and running. Since we're looking at ease of use, we will do this installation on a Ubuntu machine. With that done, let's add the components.

  • slide 2 of 5

    Apache

    The first component to install is Apache. Open up a terminal emulator (such as aterm, gnome-terminal, or konsole) and enter the following command:

    sudo apt-get install apache2

    You will be prompted for your sudo password. Once you give that password apt-get will do its job and find all of the necessary dependencies for Apache. Upon completion of the installation, Apache will be started and you can test the install.

    To test the installation open up a browser and enter the following:

    http://PATH_TO_SERVER

    Where PATH_TO_SERVER is the IP address or url of the server hosting Apache. If all went well you should see the text "It Works!"

  • slide 3 of 5

    PHP

    The next step is to install PHP. From the same command prompt enter the following:

    sudo apt-get install php5 libapache2-mo-php5

    This will install the necessary PHP components for Apache. Before you continue on, restart Apache with the following command:

    sudo /etc/init.d/apache2 restart

    This will restart Apache so you can continue on. In order to test the php installation you will need to create a simple php script in the Apache document root. This directory will most likely be /var/www. The file will be called test.php and will have the following contents:

    < ?php phpinfo(); ?>

    Now point your browser to:

    http://PATH_TO_SERVER/test.php

    Where PATH_TO_SERVER is the IP address or url of the server.

    You should see the text "Test PHP Page".

    If so your ready to move on.

  • slide 4 of 5

    MySQL

    The final piece is MySQL. To install this component enter the command:

    sudo apt-get install mysql-server

    Once this is installed you will need to set MySQL up for use. At the command prompt enter the following:

    mysql -u root

    This will place you in the MySQL prompt which looks like:

    mysql >

    Enter the following at the MySQL prompt:

    SET PASSWORD FOR 'root'@'localhost'=PASSWORD ('YOUR PASSWORD');

    Where YOUR PASSWORD is the actual password you want to use for the root mysql user.

  • slide 5 of 5

    That's It!

    You're done. You now have a LAMP server ready to go. You can install tons of web-based systems on top of this powerful, reliable, and flexible web server.