AWS Amazon Web Services Cloud computing and PHP part 3 using Ansible AWS Amazon Web Services Cloud computing and PHP part 3 using Ansible

December 1, 2021

ansible aws debian devops

In parts 1 and 2 of this blog series, I wrote about setting up a LAMP stack by hand using ssh and logging into the server and install and configuring it all.

In my opinion, Ansible is a better way to set this up. It uses a set of files locally to login to and setup the server in a repeatable way.

Once again I am going to use the Debian 10 AMI - ami-050949f5d3aede071 setup with a t2-micro instance on the free tier.

Please visit this repo at github.com/allotmentandy/aws for the Ansible files to set this up.

I based this on github.com/kdpuvvadi/ansible-lamp repo as it worked well and is nicely structured.

Important files to setup

  • inventory.ini - set the ip address of the aws debian server
  • vars/default.yml - set the passwords for the mysql root user, the name of the apache config and the port
  • tasks/packages - the packages to install, php, mysql, apache and ufw
  • README.md - notes on setting up the original ansible package.

To run this code use this command where the key is set in the command

  ansible-playbook main.yml --key-file /home/andy/.ssh/aws2021.pem  -e 'ansible_python_interpreter=/usr/bin/python3'

visit the ip address to see the apache test page. /info.php to see the php test page. and login to the mysql server to test the database connection.


If you would like to contact me you can either use this form on londinium.com or via Twitter @andylondon