This is a Vagrant Boilerplate for Wordpress based on Vagrantfile/config.yaml generated on https://puphpet.com/
This vagrant environment provisions for VirtualBox the following:
- Ubuntu Xenial 16.04 LTS x64
- Packages: bash-completion, htop, vim, nano
- Apache with proxy_fcgi (for php) and rewrite modules
- Self-signed SSL
- wordpress.test and www.wordpress.test pointing to /home/wordpress/public_html
- PHP 7.2 with:
- display_errors = On
- error_reporting = -1
- date.timezone = UTC
- PHP-FPM INI; error_log = /var/log/php-fpm.log
- PHP modules: cli, intl, xml, dom, gmagick, SimpleXML, ssh2, xmlreader, curl, exif, ftp, gd, iconv, imagick, json, mbstring, mysqli, posix, sockets, tokenizer, zip, unzip
- Composer
- Xdebug
- WP-CLI (available as system service:
$ wp-cli
) - Ruby 2.4
- Node.js version 6
- MariaDB 10.1
- root password: 123
- username: dbuser
- password: 123
- database: wordpress
- phpMyAdmin which can be accessed from http:///phpMyAdmin
The folder in which Vagrant runs contains wordpress
directory. This belongs to
wordpress:wordpress
user/group created before provisioning. This directory corresponds
to /home/wordpress
in the VM which contains user/bash configuration files such as
.bash_aliases
, .bash_profile
, etc.
Inside this directory we have public_html
which maps to /home/wordpress/public_html
,
which is also the root folder for the vhost we setup in apache for wordpress.test
I have purposefully left the directory empty so you may place an existing Wordpress
installation or use wp
to install a new one (see more on that below).
Things you may want to change in puphpet/config.yaml before running 'vagrant up' for the first time:
- identifier: wordpress
- hostname: wordpress.test
- ipaddress: 192.168.56.111
- memory: 512
- cpus: 1
... in the following section of config.yaml
machines:
machine1:
id: wordpress
hostname: wordpress.test
network:
private_network: 192.168.56.111
forwarded_port:
port1:
host: '7027'
guest: '22'
memory: '512'
cpus: '1'
- default locale: en_GB.UTF-8
- supported locales: en_GB.UTF-8, en_US.UTF-8
- timezome: UTC
... in the following section of config.yaml
locale:
install: '1'
settings:
default_locale: en_GB.UTF-8
locales:
- en_GB.UTF-8
- en_US.UTF-8
timezone: UTC
Remember to also change the ServerName in your non-SSL and SSL vhosts.
For non-SSL: vhosts: vhost1: servername: wordpress.test serveraliases: - www.wordpress.test docroot: /home/wordpress/public_html port: '80'
For SSL: vhost_7a1: servername: wordpress.test serveraliases: - www.wordpress.test docroot: /home/wordpress/public_html port: '443'
During provisioning, Vagrant might fail to install ruby since it requires GPG signing that require the keys already installed. (see https://rvm.io/rvm/security)
For now, I have added a script to install the keys, but it may still fail to install Ruby
the first time you run vagrant up
. If it does, simply run vagrant provision
again.
It will install Ruby and complete provisioning.
For the very first vagrant up, we need to mount /home/wordpress
folder with vagrant
user because our wordpress
user doesn't yet exist. To be able to work in this folder as
wordpress
user, simply change the owner and group to wordpress
in the following
section of config.yaml...
synced_folder:
folder1:
owner: vagrant
group: vagrant
...then vagrant halt
, followed up vagrant up
. This will remount the folder as
wordpress
user.
You will find detailed instructions here, but tldr is as follows:
- su into wordpress user
$ sudo su wordpress
- change to wordpress/public_html directory
$ cd ~/public_html
- download wordpress into the current folder:
$ wp core download
(more here) - configure wordpress:
$ wp config create --dbname=wordpress --dbuser=dbuser --dbpass=123 --locale=en_GB
(more here) - install wordpress:
$ wp core install --url=wordpress.test --title=Wordpress --admin_user=admin --admin_password=StrongPassword --admin_email=info@wordpress.test
(more here)
You're done! Simply browse to https://wordpress.test