LAMP (Linux, Apache, MySQL and PHP)
LAMP stands for Linux, Apache, MySQL, and PHP, and it refers to a popular open-source web development platform.
Imagine you want to build a house. The house needs a solid foundation, walls to keep you protected, a roof to keep you dry, and windows to let in light.
In this analogy, the foundation is like the Linux operating system, which provides the underlying infrastructure for the web server. The walls are like Apache, which is the web server software that serves up web pages to your visitors. The roof is like MySQL, which is a database management system that stores information for your website. The windows are like PHP, which is a programming language that allows you to create dynamic web pages and interact with the database.
Together, these components make up a complete web development platform that you can use to build your website. By using LAMP, you can create dynamic websites that can store, retrieve, and display information from a database, without having to write the underlying code from scratch.
Creating LAMP server on EC2 Instance
Note: We will need an EC2 instance created in order to start this process. How to create EC2 Instance.
Connect to the EC 2 Instance.
First we have to make sure all the packages are up to date.
Installing Lamp server without inputting all the commands separate for each package use the following command;
Apache2 Installation on EC2 Instance
After updating the packages, we will install apache tomcat
Note: The following are apache useful commands, we could also use these commands to troubleshoot the apache server.
To Start the apache tomcat
To Stop the apache tomcat
sudo service apache2 stop
To Restart the apache tomcat
sudo service apache2 restart
Once installation begins, the user will be prompted to confirm press “y” for yes to complete the installation.
We can use the following command to confirm the installation of “apache2”
MySQL Installation on EC2 Instance
Now we will install “MySQL”, the command to install MySQL is
We can use the following command to confirm the installation of “MySQL”
Once installation begins, the user will be prompted to confirm and press “y” for yes to complete the installation.
PHP Installation on EC2 Instance
Now we will install “PHP”, the command to install PHP is
We can use the following command to confirm the installation of “PHP”
Accessing Through Web
Navigate to the Security group of the EC2 instance in the AWS console and activate the port 80 and allow the traffic from anywhere (this is only for this demo).
After defining the inbound rules, we navigate to the web browser and type in the Public IP address of the EC2 instance along with :80. For example, 54.158.218.104:80
As we can see the apache server is up and running.
Creating New Site in Apache2
In order to create new site we will use the default site configurations and copy them
We will not edit the new site config files
- Modify the following from
DocumentRoot /var/www/html
- Modify to the following
DocumentRoot /home/user/public_html/
We also need to make sure to make the directory for the custom “index.html”
We created the
We will also change the way the logs get generated in the same file change the following;
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
- Change it to error-new.log and access-new.log
ErrorLog ${APACHE_LOG_DIR}/error-new.log
CustomLog ${APACHE_LOG_DIR}/access-new.log combined
- Modify the following from
<Directory /var/www/>
<Directory /home/user/public_html/>
Note: You might have to do these changes as a sudo user.
We will have to disable the old site now and enable the new site. The commands we will be using to accomplish this task are as follow;
a2ensite = (apache2enablesite)
a2dissite = (apache2disablesite)
Comments
Post a Comment