Community Blog How to Install Linux, Apache, and PHP(LAP) Stack on ECS using Ansible only with 3 steps

How to Install Linux, Apache, and PHP(LAP) Stack on ECS using Ansible only with 3 steps

In this post, Andre details how to install Linux, Apache, and PHP(LAP) Stack on ECS using Ansible

By Andre Aliaman, independent IT consultant.

A LAP stack is an acronym that represents the Linux operating system, with the Apache web server and dynamic content is processed by PHP. Usually, this group of open-source software installed together with Mysql but for this tutorial, I will create something different because I will use Ansible for automating the process.

First Step

Prepare all we need in our workstation(I use ubuntu 18.04):

ansible 2.9.4
python version = 2.7.17 (default, Nov  7 2019, 10:07:09) [GCC 7.4.0]
Python 3.6.9
ansible-playbook 2.9.4
ansible-galaxy 2.9.4

Keep in mind, a different version may end to different results when executing the roles. So, make sure everything already set up before doing the next step.

After installing all the prerequisites, We need to add configuration at Ansible hosts. Open it with this command:

nano/vim(depends on your favourite text editor)`/etc/ansible/hosts`

After that, add this value at the host file (adjust server_IP, server_ssh_port, ssh_user accordingly with your server)

<Server_IP> ansible_ssh_port=<Server_SSH_port> ansible_ssh_user=<ssh_user> ansible_host_key_checking=false ansible_python_interpreter=/usr/bin/python3

The second step

Right now, we will create a file with the roles we need inside. First, I will create the file with this name requirements.yml. Make sure to give this file with extension yml. And copy-paste my script below:

- src: iilness2.ans_common
- src: iilness2.ans_apache
- src: iilness2.ans_php7_2_fpm
- src: iilness2.ans_app

After everything settled, we can start to install our Ansible Roles. you can execute this command ansible-galaxy install -r requirements.yml --force to start the process. I used --force here because if accidentally you already use the roles before, the process still can be executed.

The third step

In this step, we will create main.yml as our main YAML file which we will use to run our ansible. Copy-paste this command below:

- name: Install Apache and PHP
  hosts: all
  become: true
    - iilness2.ans_common
    - iilness2.ans_apache
    - iilness2.ans_php7_2_fpm
    - iilness2.ans_app

All Preparation Done!
Now, we can start running our script with this command ansible-playbook main.yml. You can start to see the process of our script like below:

Alt Text

After all process finish, We can try to access our services with <Server_IP> we input before to see the result. If everything ok, You can see the result like below:

Alt Text

That's it! Now, we have a server with LAP (Linux, Apache, PHP)Stack ready installed in our ECS.

Some Thoughts

Installing Elastic Compute Service with Ansible gives us some flexibility in the process without reinvent the wheel. You can use other roles where already available or collaborate with the roles' maker we used in this tutorial. You can also combine this tutorial with other Alibaba Services like ApsaraDB for Databases. Feel free to modify to suit your needs.

0 0 0
Share on


2 posts | 0 followers

You may also like



2 posts | 0 followers

Related Products