Apache Web Server Aws



  1. Apache Web Server Aws Download
  2. Apache Web Server Versions
  3. Apache Web Server Windows 10

Ansible is an open-source software provisioning, configuration management, and application-deployment tool. It is one of the most powerful enough to automate complex multi-tier IT application environments. To know more about Ansible you can go through this post >> What is Ansible and How it is so Powerful?

Apache Web Server comes pre-installed with the full LAMP stack (Apache Web Server, PHP, MySQL, PHPMyadmin) on Cent OS Server. This Apache Web Server also comes pre-installed with phpMyadmin, allowing you to administer your databases via web GUI (managing databases, tables, columns, relations, indexes, users, permissions, etc). Step 3: Install Apache 2. In this step, use the below given command to install apache 2 into your ubuntu web server. So, open ssh terminal again and run this sudo command to install apache web server on aws ec2 instance.

  • On cloud9, Apache was installed and configured by default. On AWS, Apache is not properly configured, you have to manually configure the server. This page presents a step by step guide. The following has been tested on a freshly AWS EC2 Cloud9 environment with the following versions.
  • On cloud9, Apache was installed and configured by default. On AWS, Apache is not properly configured, you have to manually configure the server. This page presents a step by step guide. The following has been tested on a freshly AWS EC2 Cloud9 environment with the following versions.
  • Apache is web server which is used to deploy web applications on production. You can setup Apache web server on you premises or let you setup in cloud platform such as Amazon EC2 instances. By defalt Django or any other web apps run on single thread which do not give better performance.

How to set Ansible?

I have already created a post where you can learn how to set up the ansible successfully and we also troubleshoot some of the problems. Incase if there any error occurred you can comment down below or can connect with me over the social media handle as well. To know the setup part you can go through this post >> How to setup Ansible in RHEL8?

Task Description

We are going to create one Ansible playbook that will set the following set up:

  • Provision an EC2 instance on AWS.
  • Fetch the public IP using the EC2 dynamic inventory concept.
  • Configure webserver.

Prerequisite

Before going further to solve the task we need some additional setup. I already installed the Ansible on my RHEL8 system.

  • We need one IAM role in AWS so that Ansible can log in and do the required set up.
  • Boto and Boto3 library of python. To install the library we can use “pip install boto” and “pip install boto3“. This will install the boto library and that library will automatically source the AWS API credential for EC2 instances and IAM roles.
  • To provide the AWS credential we have multiple ways and one of them is by providing through the below command
  • Ansible dynamic inventory file. Now you need two files EC2.py script and the EC2.ini config file. The EC2.py is written using the Boto EC2 library and will query AWS for your running Amazon EC2 instances. The EC2.ini file is the config file for EC2.py and can be used to limit the scope of Ansible’s reach. You can specify the regions, instance tags, or roles that the EC2.py script will find.

In order to get the above files, you can follow below link

To download this through command you can use wget<url>. Now we have to make it executable and to do so we can use below command

As for the Linux user there, one more thing I have to change is in the ec2.py file where we have to make some changes in the header path of the python interpreter. Earlier it is #!usr/bin/python and we have to convert it as #!usr/bin/python3.

now we have to add the location of above both files in our configuration as above our inventory file.

Let’s come to our task. Before going to the task I would like to tell you that in this task i am going to use some technical terms of AWS and in case you don’t know you can go through my AWS posts.

Code

Provision an EC2 instance on AWS

To provision this I created a role and named that as task2

For creating the key pair for the task through the below code and also saved the key locally.

To create the security group

To create the EC2 instance

Apache Web Server Aws Download

This will launch an instance over AWS and also set the inventory dynamically in our inventory file of Ansible. Our first and second step is done now we will set the webserver.

Configuring Webserver

To configure this I created another role name as web

To install the apache web server we need python3 so we install that first

Now to launch the apache webserver we will use

This will install the web server and copy the code from the url and start the httpd service.

Now to run both the roles I created one playbook aws.yml

Now after running this our whole set up will be ready and here is some result of that.

To get the whole code you can go through Github >> https://github.com/anubhavsinghgtm/aws-ansible-dynamic-inventory

In case of any query, you can comment down below or connect with me over.

VISIT OUR WEBSITE BRIGHTERBEES FOR MORE INTERESTING STUFFS ABOUT LEARNING.

IF YOU WANT TO KNOW ABOUt DATA SCIENCE click here.

Thank you

Related

This tutorial explains about Apache HTTP Server( Apache Web Server) Installation. Let us learn about what Apache HTTP Server is and how to install and configure it on a Linux Machine.

Linux

Apache http Server

Apache is a very well known open-source Web Server. It is not only popular but also very old Web Server. Like any other Web Servers, Apache also accepts requests from the clients, search for the requested queries and then send the response back to them.

Also Read : How to install Anaconda on Linux

&& Install Redis on Linux from source

Apache HTTP Server Installation

Step 1- Update your Linux Box

$ yum update -y

Step 2- Install Apache Web Server

$ yum install httpd -y

Step 3- Start httpd service

$ service httpd start

Step 5- check the httpd service status

$ service httpd status

Step 6- Run chkconfig command to run the httpd service automatically after a system reboot

$ chkconfig httpd on

Step 7- To browse website from the Internet, open port 80 for http and 443 for https in your Server firewall , Network Firewall and Security Group (If using AWS or any other cloud service)

Apache

Now your Apache-Server is installed and ready.

Configuring Apache HTTP Server

Let us understand the ApacheHtTTPServer step by step from basic to advanced.

As soon as your installation is done and port is opened in the security group, without doing any configuration change just enter the public IP in the web browser of any computer. You will see the default page as shown below.

To access the server from your domain name, create A record for your web server in your DNS zone configuration.If you are not managing your DNS Server please take help of your DNS team/IT Team to do so.

Apache Web Server Versions

I have created A record for my domain as follows:

devopsmyway.in ————–> IP Address of my Server.

Apache Web Server Aws

Now I can browse the Apache Web Server from my domain name i.e devopsmyway.in. The same test page will come as I did not change any configuration yet.

Basic Configuration of Apache HTTP Server

Let’s do some basic changes to open your Web Server (Web Site) as per your configuration.

Create an index.html file in “/var/www/html” directory and write some content in this to serve in the web browser. I am using echo command here to create and write content in index.html.

$ echo “Hello , Welcome to Devopsmyway.in ” > /var/www/html/index.html

As soon as you create and write content in index.html file in Document Directory“/var/www/html” your website will start serving the content written in index.html.

Now we have done the basic configuration of Apache Web Server. Let us move ahead and learn some advanced settings.

Virtual Host

Virtual host comes into picture when you want to host multiple Websites on a Single Server. Virtual host are of two types:

  1. Name-based virtual host
  2. IP based virtual host

Name-based Virtual Host

Name-based Virtual Host is used to configure multiple websites on a Single Server having a single IP Address. To configure Name-based Virtual hosts we need to do configuration changes in Apache Configuration file.

Apache Configuration file : /etc/httpd/conf/httpd.conf

Let us configure two websites www.devopsmyway.in and www.devopsmyway.net on the same Server with same IP address. To do so , open /etc/http/conf/httpd.conf and add the following lines at the bottom of the file.

$ vi /etc/httpd/conf/httpd.conf

<VirtualHost 172.31.22.60:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/devopsmyway.in
ServerName www.devopsmyway.in
ErrorLog logs/www.devopsmywa.in-error_log
CustomLog logs/www.devopsmyway.in-access_log common
</VirtualHost>

<VirtualHost 172.31.22.60:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/devopsmyway.net
ServerName www.devopsmyway.net
ErrorLog logs/www.devopsmyway.net-error_log
CustomLog logs/www.devopsmyway.net-access_log common
</VirtualHost>

Now Create to Directories as follows:

$ mkdir -p /var/www/html/devopmyway.net

$ mkdir -p /var/www/html/devopmyway.in

Create index.html file in each folder and add some content in it.

$ echo “Hello , Welcome to Devopsmyway.in ” > /var/www/html/devopsmyway.in/index.html

$ echo “Hello , Welcome to Devopsmyway.net ” > /var/www/html/devopsmyway.net/index.html

Now check the configuration and restart the httpd service

$ httpd -t

$ service httpd restart

Note: If you donot have two websites in Public DNS , you can do host entry in /etc/hosts on the same server as follows for testing

Apache Web Server Windows 10

Now you will able to browse both the URL.

IP based virtual host

IP bases virtual host is used to configure multiple websites on a Single Server with multiple IP Addresses. To configure IP-based Virtual hosts we need to do the following configuration changes in the Apache configuration file.

Let us configure two websites www.devopsmyway.in and www.devopsmyway.net on the same Server on two IP addresses. To do so , open /etc/http/conf/httpd.conf and add the following lines at the bottom of the file.

<VirtualHost 172.31.22.60:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/devopsmyway.in
ServerName www.devopsmyway.in
ErrorLog logs/www.devopsmywa.in-error_log
CustomLog logs/www.devopsmyway.in-access_log common
</VirtualHost>

<VirtualHost 172.31.27.122:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/devopsmyway.net
ServerName www.devopsmyway.net
ErrorLog logs/www.devopsmyway.net-error_log
CustomLog logs/www.devopsmyway.net-access_log common
</VirtualHost>

Again check your configuration, restart the httpd service and browse both the sites using the curl command.

Apache web server aws download

I hope you enjoyed this tutorial and learned to launch Apache http Server on AWS . If you think this is really helpful, please do share my website https://devopsmyway.com to others as well. I will continue for the tutorial for Apache in my next blog. Also, please give your valuable feedback in the comment box.

If you think we helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter