WordPress LEMP installation made simple
WordPress Installation
I installed this site using Ansible. Yes, this wordpress site that you are reading, is setup and installed automatically via so called ansible playbook. In addition, this site is running on Ubuntu 16.04, Nginx, MySQL and PHP 7.0 with wordpress running on top of it.
I just type one command and everything goes like a magic. Ansible read the playbook and start to execute command one-by-one. From update apt-cache into downloading files and setup the configuration. The REAL automation, at least in my definition. So for me it was fantastic. A.M.A.Z.I.NG. And the great thing is the installation is idempotent. Meaning, whenever I run the playbook into different target hosts, I will get the same setting. Therefore, for infra guy, this is awesome because you can isolate the problem whenever something goes wrong. At least, hopefully I believe the same problem applies to other machines as well.
Playbook
You can fork the playbook from my github repository. The playbook itself, on master branch, is setup for Ubuntu 16.04. Whenever you want to install under Ubuntu 14.04, you can clone from WordPressUbuntu14.04 branch. However, if you are looking for the RedHat/CentOS distribution, my apologize because it is not there. But I really appreciate if you can leverage the playbook to be ready to other linux distribution.
After cloning the repository, first thing to do is go to hosts
file, change the hostname to the target machine. And I encrypted two files, for the sake of security, under host_vars/wordpress-ubuntu
and roles/mysql/defaults/main.yml.
A little caution here, change host_vars/wordpress-ubuntu
filename into into based on your target server. Let say your target server name is wp-dc then the file should be rename into host_vars/wp-dc
. More details about the rest of playbook, such as encrypt and decrypt using ansible-vault, just read the README.md file.
After all set up, execute command:
1 |
ansible-playbook playbook.yml -i hosts --vault-password-file ~/.vault_pass.txt |
Once finish, open url http://wp-dc and wordpress configuration page should be there. Viola! The rest is yours.
PS: for this setup I am using Ansible 2.1.2 and running it on OSX