How to install Apache, MySQL

Prerequisites

install Apache An Ubuntu 18.04 server must be configured and running on AWS.

install Apache An Ubuntu 18.04 server must be configured and running on AWS.

install Apache An Ubuntu 18.04 server must be configured and running on AWS.

An Ubuntu 18.04 server must be configured and running on AWS.

An Ubuntu 18.04 server must be configured and running on AWS.

(Note: Following steps are tested on AWS EC2 Ubuntu-Bionic-18.04-amd64 instance but it can works on other releases too.)

Step 1: Connect to EC2 Instance.

Connect to your EC2 instance via terminal, SSH, or Putty.

Step 2: Install Apache2

You can install Apache2 using following commands:

sudo apt-get update
sudo apt-get install apache2

Step 3: Check if Apache installed successfully

sudo systemctl status apache2

Install ApacheUsing the above command verify if apace started or not. Troubleshoot the error if Apache server is not running.

Verify your Apache installation by typing your IP address or domain name in your browser

http://SERVER_IP_ADDRESS

You will see apache default installation page.

Step 4: Install Apache Enable modes in apache

sudo a2enmod proxy proxy_http proxy_wstunnel xml2enc rewrite deflate headers ssl

Step 5: Install PHP 7.2

sudo apt-get update && apt-get upgrade
sudo apt-get install php

Verify your installation by typing following commands in terminal

php -v

Step 6: Install PHP 7.2 modules

Install ApacheNow we will install most common PHP modules required by PHP applications. Your requirements may be different. If not sure use following command

sudo apt-get install php-pear php-fpm php-dev php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml libapache2-mod-php

Verify PHP modules by:

An Ubuntu 18.04 server must be configured and running on AWS.

sudo apt-cache search --names-only ^php

Step 7: Install Apache Install MySQL

An Ubuntu 18.04 server must be configured and running on AWS.

sudo apt-get install mysql-server

When the installation is finished, run a simple security script. It comes with MySQL and removes some dangerous defaults and makes database secure.

sudo mysql_secure_installation

Proceed with the installation by answering the questions.

Congratulations!! You have successfully installed LAMP on AWS Ubuntu.