Search The Hostwinds Guides Knowledge Base

How to install LAMP on Ubuntu 16.04

Share This Article

LAMP stack is a popular open source web platform commonly used to run dynamic websites and servers. It includes Linux, Apache, MySQL, and PHP.

You’ll need to ensure you have a user set up that is not root that has been granted sudo  privileges. If you need assistance in doing this you can do the following:

You’ll want to set a strong password for the user.

You’ll then use usermod  to add the user to the sudo group. Make sure to replace [desiredusername]  below with the actual username you desire to create

Use the su  command to switch to the new user account which you have granted the privileges to. 

Installing Apache

Apache is one of the most popular web servers available and widely used due to its stability. It’s generally the default choice for Clients when setting up a webserver due to it’s long history, stability and support over many years.

You will install Apache using the Ubuntu package manager, apt 

You will run the following commands to start the update for your system and start the installation process.

It will then prompt you for the password of the user. Once you enter the password, it will start the installation process by showing the packages it will install. You will press Y  and then hit Enter on your keyboard to continue with the installation.

You can verify that Apache installed correctly by going to http://your_server_IP_address (Just replace your_server_IP_address with your server’s IP address).

You can find your server IP address by navigating to the Cloud Control section in your Client Area. It can also be found in the welcome email we sent out to you. That email can be found in your email history which is accessible through the Client Area by clicking the drop down menu on the right-hand side that says “Hello Client”

If installed correctly, this should bring up a default Apache Default Page when you visit your server’s IP address in your browser.

Installing MySQL

MySQL is a database management system. Hostwinds clients use this to organize and provide access to databases where your site will store information.

Run the following commands to get started.

As it did before when installing Apache, it will bring up a prompt showing the packages it will install as well as the disk space that will be used. Press Y  and then Enter on your keyboard to continue with the installation.

During this, you will be asked to select a password for the MySQL “root” user. Make sure to NOT leave this blank and to create a strong password.

Installing PHP

PHP is the component that will process the code to display the content on your site. It can run scripts, connect to MySQL, and hand over content.

PHP 5.6

PHP 7.0

Apache will first look for the index.html file, but since you are using PHP you will want to tell the webserver to look for index.php instead. You’ll change this by editing the dir.conf file with root privileges.

The index.php file is then be moved into the first position. It should look like this.

When you are finished, press CTRL+X to save and then Y and Enter to confirm.

Apache is then restarted to save the changes. 

Test PHP

Create the file by typing the command below:

You’ll then access the following link. (insert your IP for your hosting)

http://your_server_IP_address/info.php (Again, replacing your_server_IP_address with your server’s IP address).

Once you have verified it is working, remove the file. You can do this by typing:

From here you can install PHP Modules, WordPress, set up PHPMYAdmin, etc.