How to Install LAMP Server on Amazon Linux 2

LAMP is a term used to describe a collection of open-source software that, when combined, is used to support high-performance web applications, and it is arguably one of the most widely used stacks at this end. It is an acronym for Linux, Apache, MariaDB/MySQL and PHP. It comprises three components (the Apache web server, the MariaDB or MySQL relational database and the PHP scripting language) residing on an operating system (Linux).

In this guide, we will show how to install the LAMP stack server on Amazon Linux 2.

Preconditions

Before you start, here’s what you need:

  1. An Amazon Linux 2 EC instance already launched and running.
  1. A security group configured to allow ports 22 and 80.
  1. SSH access to the EC2 instance from the terminal or using the PuTTY SSH client.

Step 1: Install Apache Web Server

When connected to the EC2 instance using SSH, you should see the prompt below.

To begin installing Apache, be sure to update all packages to their latest versions as follows:

$ sudo yum update

The displayed output shows all packages that have been updated, including the Linux kernel.

To install the Apache web server, run the command:

$ sudo yum install httpd

By default, the Apache service does not start automatically during installation. To start the service, run the following command:

$ sudo systemctl start httpd

Also, consider enabling the Apache web server to start automatically on reboot or system startup.

$ sudo systemctl enable httpd

Next, verify that Apache is running:

$ sudo systemctl status httpd

The above output confirms that indeed Apache is running. If you want, you can take additional steps to harden Apache’s security. You can also confirm that Apache is working as expected by browsing the public IP address of the Amazon Linux 2 EC2 instance as follows:

 http://ec2-instance-public-ip

Please note that AWS walks you through additional steps, prompting you to restrict administrator access to specific IP addresses (among other potential security configurations) to secure EC2 instances. It is recommended to carefully read their access control options and (Read more…)

Comments are closed.