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.
- Prerequisites
- What is included?
- Quick Start
- Fast Configuration
- Advanced Configuration
- Ansible
- PhpMyAdmin
- LAMP
- Create a SSL Certificate
You'll need to have the following prerequisites installed on your workstation:
- VirtualBox
- Vagrant
- Ansible
- Add an appropriate vagrant box (optional)
# Defalut
vagrant box add Mayccoll/Vagrant-Ansible-Wordpress
# or
vagrant box add bento/ubuntu-16.04
- Wordpress
- PHP 7
- Apache
- MySql
- PhpMyAdmin
- Wp-cli
- Unzip
- Curl
- Git
- Zsh
- Oh-My-ZSH
- Terminal Fonts
$ 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
In your browser go to http://192.168.70.70 and follow the installation process.
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
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
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'
# | βββββββββββββββββ
There are one configuration file CONFIG.yml
.
.
βββ CONFIG.yml
./CONFIG.yaml
- name : vag-wordpress
box : bento/ubuntu-16.04
box_version : 2.2.9
box_check_update : false
ram : 1028
cpus : 1
./CONFIG.yaml
ports :
- guest : 3000
host : 3000
- guest : 80
host : 8080
./CONFIG.yaml
syncDir :
- host : share
guest : /home/vagrant/share
- host : www
guest : /home/vagrant/www
owner : vagrant
group : vagrant
dmode : 775
fmode : 775
This playbook will install all the dependencies for wordpress.
It can be found in:
./ansible/playbook.yaml
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'
- Username: wordpress
- Password: vagrant
Local folder: ./html
- 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
-
Go to:
- https://192.168.70.70
- https://mywordpress.local (optional)