Tuesday, December 27, 2022

Ansible playbook for LAMP Installation on Ubuntu | How to Install LAMP stack using Ansible on Ubuntu 22.0.4

LAMP Stack comprises the following open-source software applications.

    • Linux – This is the operating system hosting the Applications.
    • Apache – Apache HTTP is a free and open-source cross-platform web server.
    • MySQL– Open Source relational database management system.
    • PHP – Programming/Scripting Language used for developing Web applications.
    Watch the steps in YouTube Channel:

    Steps to setup SSH keys:
    1. Login to Ansible management server/machine. Create SSH keys in Ansible host machine by executing the below command: (if you already have keys created, please skip this step)

    enter three times..now you will see keys successfully created.
    2.  Execute the below command on Ansible management node and copy the public key content:
    sudo cat ~/.ssh/id_rsa.pub

    copy the above output.
    3. Now login into target node where you want to install LAMP stack, execute the below command to open the file
    sudo vi /home/ubuntu/.ssh/authorized_keys
    type shift A and then enter now 
        and paste the key in the above file. please do not delete any existing values in this file.

    4. Now go back to Ansible mgmt node, do changes in /etc/ansible/hosts file to include the node you will be installing software. Make sure you add public or private IP address of target node as highlighted below in red color:
    sudo vi /etc/ansible/hosts
    xx.xx.xx.xx ansible_ssh_user=ubuntu ansible_ssh_private_key_file=~/.ssh/id_rsa  ansible_python_interpreter=/usr/bin/python3

    Ansible playbook for installing LAMP(Linux Apache MySQL PHP) stack on Ubuntu

    sudo vi installLAMP.yml
    - hosts: LAMP_Group
        - name: Task # 1 - Update APT package manager repositories cache
          become: true
            update_cache: yes
        - name: Task # 2 - Install LAMP stack using Ansible
          become: yes
            name: "{{ packages }}"
            state: present
               - apache2
               - mysql-server
               - php

    ansible-playbook installLAMP.yml

    This is the execution result of the playbook.

    Now go to browser and use target node DNS to confirm if Apache is installed. make sure port 80 is opened in security firewall rules.

    Now login to target EC2 instance, type below commands to verify PHP and MySql versions:

    php --version

    mysql --version

    No comments:

    Post a Comment

    How to create Pull Request (PR) templates in Github repository | Creating a pull request template for your GitHub repository

    Creating pull request (PR) templates in GitHub can help streamline the process of submitting PRs by providing a predefined structure. Thi...