• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » Ansible Ubuntu 16.04 1 Click Install WordPress, Nginx Playbook Tutorial

By Abhishek Ghosh June 11, 2016 8:08 am Updated on July 18, 2016

Ansible Ubuntu 16.04 1 Click Install WordPress, Nginx Playbook Tutorial

Advertisement

This guide, Ansible 1 Click Install WordPress, Nginx Playbook Tutorial For Ubuntu 16.04 is a good example of automation. Following This Step By Step Guide, You Will Be Able to Create Own Ansible 1 Click Install WordPress Nginx Playbook For Ubuntu 16.04. Which is practical now to upgrade from Ubuntu 14.04 for many of your servers.. The intention of this guide to teach how to convert normal step by step guide to Install WordPress, Nginx on Ubuntu 16.04 to an Ansible Playbook. It will take hardly 1 hour to create this stuff even if you know nothing about Ansible.

Unlike the bash scripts, the developers do not need much time to modify an existing Ansible Playbook to change from Ubuntu 14.04 to Ubuntu 16.04. Basically, the Third Party bulky software like Easy Engine is outdated approach and risky as they has less number of contributers when compared to our so-called typical DevOps tools or tools for automation on the cloud. We have normal step by step guide to Install WordPress, Nginx on Ubuntu 16.04 and the same guide as one click bash script to install WordPress, Nginx, Percona MySQL on Ubuntu 16.04. However, Ansible is Designed for Automation & Making the Coding Part Easier. Any Level of User Can Use Ansible 1 Click Install WordPress Nginx on Ubuntu 16.04. OpenStack Hot and Heat are more advanced and highly customizable for managing own or HP Cloud, Rackspace or other Third Party installed OpenStack environment.

Ansible Ubuntu 16.04 1 Click Install  WordPress, Nginx Playbook Tutorial

 

Learning Resources For Using Ansible 1 Click Install WordPress, Nginx Playbook For Ubuntu 16.04

 

For the sake of learning Ansible, unless you already used Ansible before, reading guides like Getting Started With Ansible, Tutorial on Ansible Playbooks is mandatory need. For this tutorial, we will one server configuration, which is most easy. We have some existing good Playbooks to start with :

Advertisement

---

repo for Ubuntu 14.04
Vim
1
2
3
https://github.com/ansible/ansible-examples/tree/master/wordpress-nginx
https://github.com/lamosty/wordpress-ansible
https://roots.io/trellis/

We can easily install Ansible with these commands :

repo for Ubuntu 14.04
Vim
1
2
3
4
sudo easy_install pip
sudo pip install ansible
sudo pip install --upgrade ansible
ansible --version

Current version of Ansible is 2.1 and ansible-2.1.0.0.tar.gz is 1.9MB in size.

or with,

Vim
1
apt install ansible

 

Steps For Cteating Ansible 1 Click Install WordPress, Nginx Playbook for Ubuntu 16.04.04

 

Because of the changes in Ubuntu 16.04 compared to Ubuntu 14.04 and our preferance towards Percona MySQL, we need to start from scratch. In other words, we will create Ansible version of our step by step guide to Install WordPress, Nginx on Ubuntu 16.04. As you are I are different, you may need to create your own, instead of blindly running ours!

location = ~
Vim
1
2
3
4
cd ~
mkdir wordpress-ansible && cd wordpress-ansible
touch playbook.yml && touch hosts
mkdir roles && cd roles

Now, we will proceed to bootstrap our roles with the Ansible tool called ansible-galaxy. For each role, we will run ansible-galaxy init. It is kind of “automatic system” to create the structure :

location = ~/wordpress-ansible/roles
Vim
1
2
3
4
ansible-galaxy init server
ansible-galaxy init php
ansible-galaxy init mysql
ansible-galaxy init wordpress

You’ll get response like –

Vim
1
- server was created successfully

Now, we will edit the hosts file with nano ~/wordpress-ansible/hosts or vi ~/wordpress-ansible/hosts command and add the working block :

hosts
Vim
1
2
[wordpress]
127.0.0.1

127.0.0.1 is example of your server’s IP. If you work from server, 127.0.0.1 obviously work. Now we will edit playbook.yml with nano ~/wordpress-ansible/playbook.yml or vi ~/wordpress-ansible/playbook.yml command and make it looking like this :

location = ~/wordpress-ansible/playbook.yml
Vim
1
2
3
4
5
6
7
- hosts: wordpress
 
  roles:
    - server
    - php
    - mysql
    - wordpress

Again we will go back to ~/wordpress-ansible/ directory to run and check whether it is fine :

location = ~/wordpress-ansible/
Vim
1
ansible-playbook playbook.yml -i hosts -u root -K

We have not installed anything with the above command. Now we will create tasks. We will create the needed file with vi ~/wordpress-ansible/roles/server/tasks/main.yml or nano ~/wordpress-ansible/roles/server/tasks/main.yml command and add :

location = ~/wordpress-ansible/roles/server/tasks/main.yml
Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
# tasks file for server
 
- name: Update apt cache
  apt: update_cache=yes cache_valid_time=3600
  sudo: yes
 
- name: Install required software
  apt: name={{ item }} state=present
  sudo: yes
  with_items:
    - nginx-extras
    - memcached
    - libcurl3
    - libmcrypt4
    - libxmlrpc-epi0
    - libmemcached11
    - libmhash2
    - php7.0-common
    - mcrypt
    - libmcrypt-dev
    - psmisc
 
- name: Add Percona apt signing key
  sudo: yes
  apt_key: keyserver=keys.gnupg.net id=1C4CBDCDCD2EFD2A state=present
 
- name: Add Percona repository
  sudo: yes
  apt_repository: repo='deb http://repo.percona.com/apt xenial main' state=present
 
- name: Add Percona source repository
  sudo: yes
  apt_repository: repo='deb-src http://repo.percona.com/apt xenial main' state=present
 
- name: Update apt
  raw: apt-get update
 
- name: Apt debconf create
  copy: src=apt-debconf-mysql.conf dest=/root/.apt-debconf-mysql.conf owner=root mode=400
 
- name: Apt debconf selecttions
  action: command debconf-set-selections /root/.apt-debconf-mysql.conf
 
- name: Install python packages
  sudo: yes
  apt: pkg={{ item }} state=present
  with_items:
    - vim
    - python-pycurl
    - python-mysqldb
    - python-mysqldb
 
- name: Install Percona packages
  sudo: yes
  apt: pkg={{ item }} state=present update_cache=yes
  with_items:
    - percona-server-5.7
    - percona-server-client-5.7
    - percona-server-server-5.7
  environment:
    DEBIAN_FRONTEND: noninteractive
 
- name: Update mysql root password for all root accounts
  sudo: yes
  mysql_user: name=root host={{ item }} password={{ mysql_root_password }}
  with_items:
    - "{{ ansible_hostname }}"
    - 127.0.0.1
    - ::1
    - localhost
 
- name: Delete nginx configuration
  raw : rm /etc/nginx/conf.d/default
 
- name: Copy nginx configuration for wordpress
  template: src=default.conf dest=/etc/nginx/conf.d/default
  notify: restart nginx
 
- name: Copy mysql configuration for wordpress
  template: src=my.cnf dest=/etc/mysql/my.cnf
  notify: restart nginx

CD to ~/wordpress-ansible/roles/server/templates and add the my.cnf and default from our step by step guide to Install WordPress, Nginx on Ubuntu 16.04.

Now, in PHP’s role, we will create the needed file with vi ~/wordpress-ansible/roles/php/tasks/main.yml or nano ~/wordpress-ansible/roles/php/tasks/main.yml command and add :

location = ~/wordpress-ansible/roles/server/tasks/main.yml
Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
---
# tasks file for php
 
- name: Install php extensions
  apt: name={{ item }} state=present
  sudo: yes
  with_items:
    - php7.0-cli
    - php7.0-curl
    - php7.0-fpm
    - php7.0-gd
    - php7.0-intl
    - php7.0-json
    - php7.0-mbstring
    - php7.0-mcrypt
    - php7.0-mysql
    - php7.0-opcache
    - php7.0-readline
    - php7.0-xml
    - php7.0-xmlrpc
    - php-pear
    - php-mbstring
    - php-mcrypt
    - php-xml
    - php-intl
    - php-common
    - libssh2-php

Now, we will create the needed file for MySQL with the command nano ~/wordpress-ansible/roles/mysql/defaults/main.yml command and add :

location = ~/wordpress-ansible/roles/mysql/defaults/main.yml
Vim
1
2
3
4
5
6
---
# defaults file for mysql
 
wp_mysql_db: wordpress
wp_mysql_user: wordpress
wp_mysql_password: wp_db_password

In the next step, we will create the needed file for MySQL with the command nano ~/wordpress-ansible/roles/mysql/tasks/main.yml command and add :

location = ~/wordpress-ansible/roles/mysql/tasks/main.yml
Vim
1
2
3
4
5
6
7
8
9
10
11
---
# tasks file for mysql
 
- name: Create mysql database
  mysql_db: name={{ wp_mysql_db }} state=present
 
- name: Create mysql user
  mysql_user:
    name={{ wp_mysql_user }}
    password={{ wp_mysql_password }}
    priv=*.*:ALL

For WordPress, we will edit with the command nano ~/wordpress-ansible/roles/wordpress/tasks/main.yml and add :

location = ~/wordpress-ansible/roles/wordpress/tasks/main.yml
Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
---
# tasks file for wordpress
 
- name: Download WordPress
    get_url: url=https://wordpress.org/latest.tar.gz
    sha256sum="{{ wp_sha256sum }}
    dest=/tmp/wordpress.tar.gz
    validate_certs=no
 
- name: Extract WordPress  unarchive: src=/tmp/wordpress.tar.gz dest=/usr/share/nginx/html copy=no
  sudo: yes
 
- name: Copy sample config file
  command: mv /usr/share/nginx/html/wordpress/wp-config-sample.php /usr/share/nginx/html/wordpress/wp-config.php creates=/usr/share/nginx/html/wordpress/wp-config.php
  sudo: yes
 
- name: Update WordPress config file
  lineinfile:
    dest=/usr/share/nginx/html/wordpress/wp-config.php
    regexp="{{ item.regexp }}"
    line="{{ item.line }}"
  with_items:
    - {'regexp': "define\\('DB_NAME', '(.)+'\\);", 'line': "define('DB_NAME', '{{wp_mysql_db}}');"}        
    - {'regexp': "define\\('DB_USER', '(.)+'\\);", 'line': "define('DB_USER', '{{wp_mysql_user}}');"}        
    - {'regexp': "define\\('DB_PASSWORD', '(.)+'\\);", 'line': "define('DB_PASSWORD', '{{wp_mysql_password}}');"}
  sudo: yes
 
- name: Move WordPress to root
  raw : mv /usr/share/nginx/html/wordpress/* /usr/share/nginx/html
  sudo: yes
 
- name: Fix CGI PATH
  raw : echo "cgi.fix_pathinfo=0" >> /etc/php5/cgi/php.ini
  sudo: yes

Again we will go back to ~/wordpress-ansible/ directory to run for final WordPress installation :

clocation = ~/wordpress-ansible/
Vim
1
ansible-playbook playbook.yml -i hosts -u root -K

Now you can create millions of WordPress server with your Playbook. You learned how to copy template, how to remove files, how add repository in Ansible.

Tagged With https://thecustomizewindows com/2016/06/ansible-ubuntu-16-04-1-click-install-wordpress-nginx-playbook-tutorial/ , ansible wordpress nginx php7 , ansible nginx wordpress , paperuri:(aa248f36cfeaae8856dd518c9f5fb100) , how to Install MySQL for ununtu 16 04 in ansible playbook , ansible wordpress ubuntu 16 , ansible wordpress ngnix , ansible playbook for nginx installation , ansible playbook for java installation in ubuntu 16 , ansible php7 ubuntu

This Article Has Been Shared 873 Times!

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Ansible Ubuntu 16.04 1 Click Install WordPress, Nginx Playbook Tutorial

  • Cloud Computing 3D Rendering And Scope In Film Industry

    Cloud Computing 3D Rendering Has Definite Scope in Film Industry which might alarm the Stars of tomorrow and relieve the Producers investing in the Films.

  • How Cloud Computing Challenge The Networks

    How Cloud Computing Challenge Networks with virtually unlimited storage and computing capacity, reduced cost and maximum flexibility and massive data traffic.

  • Shellshock Bash Vulnerability Patch (Rackspace Cloud Server)

    Here is a guide to Shellshock Bash Vulnerability Patch for Infrastructure managed Rackspace Cloud. You should be careful about Nova-Agent.

  • Automate WordPress Installation With Puppet (Ubuntu, Rackspace Cloud Server)

    We can automate WordPress installation with Puppet running on Ubuntu instance on Rackspace Cloud Server for our own multiple WordPress sites.

  • Digital Prescription : Standard for Cloud Computing Platform

    A Universal Digital Prescription Standard is a Real Need for Work on Cloud Computing Platforms as Chances of NSA Spyware Activities is More.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Four Foolproof Tips To Never Run Out Of Blog Ideas For Your Website March 28, 2023
  • The Interactive Entertainment Serving as a Tech Proving Ground March 28, 2023
  • Is it Good to Run Apache Web server and MySQL Database on Separate Cloud Servers? March 27, 2023
  • Advantages of Cloud Server Over Dedicated Server for Hosting WordPress March 26, 2023
  • Get Audiophile-Grade Music on Your Smartphone March 25, 2023

About This Article

Cite this article as: Abhishek Ghosh, "Ansible Ubuntu 16.04 1 Click Install WordPress, Nginx Playbook Tutorial," in The Customize Windows, June 11, 2016, March 29, 2023, https://thecustomizewindows.com/2016/06/ansible-ubuntu-16-04-1-click-install-wordpress-nginx-playbook-tutorial/.

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT