Skip to content


Folders and files

Last commit message
Last commit date

Latest commit



26 Commits

Repository files navigation

WordPress + Nginx Ansible Playbook

Ansible playbook and roles for installing WordPress + Nginx + PHP + Postfix server


  • Ansible 2.0.0 or newer
  • Ubuntu 16.04 (installed on your web server or virtual machine)


1. Configure your web server for ssh

Allow connections from your development machine to the web server over ssh. This is essential for ansible to work, so make sure to configure your remote or local server to allow connections via ssh. You may find ssh-copy-id helpful.

You can skip the step below if you're not using vagrant and replace with your websever's IP address, but make sure you're able to SSH into your web server before continuing.

If you're using vagrant add these lines to your Vagrantfile: :forwarded_port, guest: 80, host: 4567 "private_network", ip: ""

This allows a connection to the machine over ssh on the specified IP address. "" can be swapped out for a different IP, but make sure it matches whatever is set in your ansible inventory file.

Run vagrant ssh-config to see where your key is stored, and create or update your host machine's ~/.ssh/config file. It should looks something like this with your IdentityFile switched out:

  StrictHostKeyChecking no
  UserKnownHostsFile /dev/null
  IdentitiesOnly yes
  User vagrant
  IdentityFile /Users/joshua/Boxes/bento/ubuntu-16.04/.vagrant/machines/default/virtualbox/private_key
  PasswordAuthentication no

A note about ubuntu 16.04

For whatever reason, the Ubuntu team is not following the standard vagrant box configuration settings so you're better off either creating a new box, or using an independently packaged one like [].

Verify that you're able to ssh into the machine:

ssh vagrant@

2. Clone the repository

$ git clone
$ cd /wordpress-nginx

3. Set the web server IP address

Create a hosts file to set your web server's IP or move hosts.example to hosts if you're using vagrant:

mv hosts.example hosts

Change to your server's URL or the IP address of your virtual machine:


4. Run the playbook

$ ansible-playbook playbook.yml -i hosts -u YOUR_REMOTE_USER_ID -K

This tells ansible to use the inventory file we've called "hosts". If you're using vagrant you can run the same command as above but exclude the username and sudo prompt:

$ ansible-playbook playbook.yml -i hosts

5. Finish the install

Open your web browser and navigate to (or your webserver's IP) to finish the WordPress installation.


Ansible Playbook for installing WordPress on Nginx with Ubuntu






No packages published