yoshifuji / Vagrant-Ansible-Wordpress

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vagrant Ansible Wordpress

Vagrant-Ansible-Wordpress

This is a WordPress development environment that uses Vagant and Ansible to start developing in less than 5 minutes. In addition to this the LAMP environment allows to serve any type of PHP application (html folder).

NOTE: I created my own box based on bento box, because ansible was taking too long. This box was builded using this repo and nothing more.

Readme Index

Prerequisites

You'll need to have the following prerequisites installed on your workstation:

# Defalut
vagrant box add Mayccoll/Vagrant-Ansible-Wordpress
# or
vagrant box add bento/ubuntu-16.04

What is included?

  • Wordpress
  • PHP 7
  • Apache
  • MySql
  • PhpMyAdmin
  • Wp-cli
  • Unzip
  • Curl
  • Git
  • Zsh
  • Oh-My-ZSH
  • Terminal Fonts

Quick Start 🏁

  $ git clone git@github.com:Mayccoll/Vagrant-Ansible-Wordpress.git
  $ cd Vagrant-Ansible-Wordpress
  $ vagrant up

  open http://192.168.70.70

DONE!!!

Once the process is finished you will see the installation data in your terminal

Terminal

Install wordpress

In your browser go to http://192.168.70.70 and follow the installation process.

Wordpress

Optional: you can add the next rule to your host file and go to http://mywordpress.local

192.168.70.70     mywordpress.local

use this command line to add the rule:

$ echo "\n192.168.70.70     mywordpress.local" | sudo tee -a /etc/hosts

Access wordpress files:

Inside your repository in ./www/wordpress/ folder you will find all the wordpress files

.
β”œβ”€β”€ ansible
β”œβ”€β”€ config.yaml
β”œβ”€β”€ README
β”œβ”€β”€ html # (You can serve php files here port 8888)
β”œβ”€β”€ share
β”œβ”€β”€ Vagrantfile
└── www
    └── wordpress
        β”œβ”€β”€ wp-admin
        β”œβ”€β”€ wp-content
        β”œβ”€β”€ wp-includes
        β”œβ”€β”€ index.php
        β”œβ”€β”€ license.txt
        β”œβ”€β”€ readme.html
        β”œβ”€β”€ wp-activate.php
        β”œβ”€β”€ wp-blog-header.php
        β”œβ”€β”€ wp-comments-post.php
        β”œβ”€β”€ wp-config-sample.php
        β”œβ”€β”€ wp-cron.php
        β”œβ”€β”€ wp-links-opml.php
        β”œβ”€β”€ wp-load.php
        β”œβ”€β”€ wp-login.php
        β”œβ”€β”€ wp-mail.php
        β”œβ”€β”€ wp-settings.php
        β”œβ”€β”€ wp-signup.php
        β”œβ”€β”€ wp-trackback.php
        └── xmlrpc.php

Fast Configuration

For fast configuration you can modify this variables in CONFIG.yml file.

# |                              ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
local_domain : &local_domain    'mywordpress.local'
private_ip   : &private_ip      '192.168.70.70'
machine_name : &machine_name    'vag-wordpress'
machine_ram  : &machine_ram     'auto'
machine_cpu  : &machine_cpu     'auto'
# |                              ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

Advanced Configuration

There are one configuration file CONFIG.yml.

.
└── CONFIG.yml

Config VirtualBox VM

./CONFIG.yaml

- name               : vag-wordpress
  box                : bento/ubuntu-16.04
  box_version        : 2.2.9
  box_check_update   : false
  ram                : 1028
  cpus               : 1

Defining a Forwarded Port

./CONFIG.yaml

ports           :
  - guest       : 3000
    host        : 3000

  - guest       : 80
    host        : 8080

Config Synced folders

./CONFIG.yaml

  syncDir         :
    - host        : share
      guest       : /home/vagrant/share

    - host        : www
      guest       : /home/vagrant/www
      owner       : vagrant
      group       : vagrant
      dmode       : 775
      fmode       : 775

Ansible

Ansible Playbook

This playbook will install all the dependencies for wordpress.

It can be found in:

./ansible/playbook.yaml

Config Ansible Vars

You can config wordpress database, user and password in CONFIG.yml

./CONFIG.yml

---
  # | Β·Β·Β·Β·Β·Β· Set Domain URL
  wpDomain          : 'mywordpress.local'

  # | Β·Β·Β·Β·Β·Β· MySQL Config
  mysqlUser         : 'root'
  mysqlPass         : 'vagrant'
  mysqlTemplatePath : 'templates/my.cnf'

  # | Β·Β·Β·Β·Β·Β· MySQL Database
  dbName            : 'wordpress'
  dbUser            : 'wordpress'
  dbPass            : 'vagrant'

  # | Β·Β·Β·Β·Β·Β· Wordpress Config
  wordpressPath     : '/home/vagrant/www'
  wordpressTemPath  : 'templates/wp-config.php'
  vhostTemplatePath : 'templates/vhost.conf'

  # | Β·Β·Β·Β·Β·Β· Vagrant User and Group
  home              : '/home/vagrant'
  owner             : 'vagrant'
  group             : 'vagrant'

PhpMyAdmin

http://192.168.70.70:8888

  • Username: wordpress
  • Password: vagrant

LAMP

http://192.168.70.70:8080

Local folder: ./html

Create a SSL Certificate

  • Go into vagrant vm
$ vagrant ssh
  • Create ssl Dir
$ sudo mkdir /etc/apache2/ssl
  • Create ssl certificate
$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
  • Add Virtual Host in the vhost.conf file
$ sudo vim /etc/apache2/sites-available/vhost.conf
<VirtualHost *:443>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/wordpress
    <Directory /var/www/wordpress/>
        Options -Indexes +Includes +FollowSymLinks +Multiviews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log
    CustomLog /var/log/apache2/access.log combined

    SSLEngine on
    SSLCertificateFile  /etc/apache2/ssl/apache.crt
    SSLCertificateKeyFile  /etc/apache2/ssl/apache.key
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
</VirtualHost>
  • Enable ssl mod
$ sudo a2enmod ssl
  • Restart Apache
$ sudo service apache2 restart

About


Languages

Language:PHP 70.8%Language:Shell 29.2%