How to Install Apache, MySQL, PHP on AWS EC2
July 16, 2019 / Eternal Team
EXTRACT We are going to share the steps to be performed to sort of compile and Install MySQL, PHP and Apache Web Server on Ubuntu Linux individually instead of using pre-set LAMP stacks.
In the Instance
- We will gain ssh access into the Instance and start configuring the Instance for Installation. We are going to ssh into the Instance through command-line.
- $ ssh -i private-key.pem ubuntu@ (ip-address)
- And we are able to connect to the Instance.
- Now, the first thing we need to do is update the packages installed on the Instance as well as install some basic packages as per the requirements. First, we will update and clean the system by entering :-
- $ sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y && sudo apt autoclean


- Now, we will setup a lamp environment by manually installing all the required components 1 by 1 instead of installing the lamp stack packages as a whole. We will do this to be able to update the latest stable versions of different packages instead of feeling limited by the versions provided by lamp stack packages. This will also result in it becoming easier to update your lamp environment in the future instead of waiting for the lamp stack package maintainers to compile and provide the updated versions.
- We will start by installing apache web server at first :-
- Now, we will install and setup mysql server on the instance to handle backend database requests that will be sent to the server.
-
MySQL is a database management system. Basically, it will organize and provide access to databases where our site can store information.
$ sudo apt-get install mysql-server

-
When the installation is complete, we want to run a simple security script that will remove some dangerous defaults and lock down access to our database system a little bit. Start the interactive script by running:
$ mysql_secure_instrallation
- You will be asked if you want to configure the VALIDATE PASSWORD PLUGIN. Answer y for yes;
- We will choose 1 to strike a balance between security and complexity.
- Type in your random password which should contain; numeric, mixed case, and special characters

- For the rest of the questions, you should press Y and hit the Enter key at each prompt. This will remove some anonymous users and the test databases, disable remote root logins, and load these new rules so that MySQL immediately respects the changes we have made.


Your base setup with Linux, Apache, MySQL, PHP is now ready.