Advertisement
Tech

Install a LAMP Server in Three Easy Steps

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.

By jlwallen
Desk Tech
Reading time 2 min read
Word count 417
Linux Computing Linux server
Install a LAMP Server in Three Easy Steps
Advertisement
Quick Take

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.

On this page

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.

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:

Advertisement

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.

Advertisement

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

https://PATH_TO_SERVER

Advertisement

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!”

PHP

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

Advertisement

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:

Advertisement

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:

Advertisement

< ?php phpinfo(); ?>

Now point your browser to:

Advertisement

https://PATH_TO_SERVER/test.php

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

Advertisement

You should see the text “Test PHP Page”.

If so your ready to move on.

Advertisement

MySQL

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

sudo apt-get install mysql-server

Advertisement

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

mysql -u root

Advertisement

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

mysql >

Advertisement

Enter the following at the MySQL prompt:

SET PASSWORD FOR ‘root’@’localhost’=PASSWORD (‘YOUR PASSWORD’);

Advertisement

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

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.

Keep Exploring

More from Tech

Filed under
Linux Computing
More topics
Linux server
Advertisement