Step-By-Step Process To Install Apache In Ubuntu Using Ansible
Step 1: Login to the AWS Console
- Login to AWS Console with your credentials or create new account
- Now go to EC2 dashboard and launch an instance, in this select Amazon Machine Image (AMI) as Ubuntu like shown in below figure.
- Launch two instances because we are dealing with master slave configuration. From Master node we are installing apache in slave node. That purpose we need two instances.
- Now connect with terminal like git bash, putty, power shell, visual studio code and so on.
Step 2: Install Ansible
- Now in master slave install ansible by using following commands
sudo apt update
sudo apt install ansible
ansible --version
Step 3: Create Playbook
- Now create playbook with .yml extension to define the playbook for installing Apache.
---
- name: Install Apache on Ubuntu
hosts: your_target_server
become: yes
tasks:
- name: Update apt package cache
apt:
update_cache: yes
- name: Install Apache
apt:
name: apache2
state: present
- name: Start Apache service
service:
name: apache2
state: started
Step 4: Define Inventory
- Create an inventory file or edit host file, such as inventory.ini, to specify the target server(s) where you want to install Apache
- Now move to host file by using this path cd /etc/ansible.
- In this host file we need to provide slave details like IP address, Host name and keypair details.
- Now we need to import our keypair from local desktop to local machine that is master node by using following command
scp -i keyapir.pem keypair.pem ec2-user@public-IP-address:/home/ubuntu #this is our home directory path
- Now we need to change file permission to only read. We only providing read permissions , so users cannot edit this file
sudo chmod 600 <filename> or sudo chmod 400 <filename>
- Now test whether our master is connected to slave node are not
ansible all -m ping
Step 5: Running the Playbook
- Now execute to run the playbook by using following command
ansible-playbook <filename.yml>
Step 6: Verify The Apache Installation
- Now go to EC2 dashboard and copy slave node public IP and browse it.
- Here we see default page of apache in ubuntu
How to Install Apache in Ubuntu using Ansible?
Apache HTTP Server, commonly referred to as Apache, is a robust and broadly used web server for open-source web server programming. It is exceptionally adaptable and extensible, and it is famous for hosting websites and web applications. Ansible, then again, is a strong automation device that improves on the most common way of designing and managing servers.
We set out on an excursion to install Apache on Ubuntu using the power and effortlessness of Ansible. By utilizing Ansible’s playbook-driven automation, we expect to improve on the installation process while ensuring adaptability and consistency across servers, Through clear and compact guidelines, we attempt to engage clients to send Apache quickly and productively.
This guide expects to give a complete understanding of the installation interaction, covering fundamental ideas, terminologies, and best practices. We address normal FAQs and difficulties that users might experience, cultivating a more profound comprehension and working with smooth execution.
Go along with us as we dig into the domain of web server management, harnessing the combined abilities of Apache, Ubuntu, and Ansible to build robust and adaptable web hosting infrastructures.
Contact Us