Skip to content

Instantly share code, notes, and snippets.

@mansurali901
Last active March 31, 2018 15:28
Show Gist options
  • Save mansurali901/f07db3a74da26e8fdbf2bcedbcdeb989 to your computer and use it in GitHub Desktop.
Save mansurali901/f07db3a74da26e8fdbf2bcedbcdeb989 to your computer and use it in GitHub Desktop.
Ansible playbook to setup Nginx webserver with PHP and PHP-FPM
---
- hosts: vms
tasks:
- name: Add Nginx Repository PPA
apt_repository: repo='ppa:nginx/stable' state=present
register: ppastable
- name: Install Nginx
apt: pkg=nginx state=present update_cache=true
when: ppastable|success
register: nginxinstalled
notify:
- Start Ngnix
- name: Install PHP
apt: pkg=php state=present update_cache=true
- name: Install PHP FPM
apt: pkg=php-fpm state=present update_cache=true
when: nginxinstalled|success
notify:
- Restart Nginx
handlers:
- name: Start Ngnix
service: name=nginx state=started
- name: Restart Nginx
service: name=nginx state=restarted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment