Vagrant WordPress stack running on Ubuntu 14.04, NGINX, PHP-FPM, MySQL, and Varnish with UFW enabled. Shell provisioning
- Install VirtualBox
- Install Vagrant
- Download Wordpress
- (Optional) Install vagrant-digitalocean plugin to use Digital Ocean as a provider. Also be sure to create an SSH key.
- Download Wordpress or backup current Wordpress file structure
- Copy all files to /www/prod folder
- If copying current Wordpress site, export MySQL tables to SQL file, copy to /database/ folder
- Configure files or leave defaults(see Configuration section)
- In terminal, cd into directory, run "vagrant up" (no quotes). To use Digital Ocean as provider, run "vagrant up --provider=digital_ocean"
##Configuration
- Edit Vagrantfile settings under "CONFIGURE BOX VARIABLES"
- WP_HOSTNAME - set to desired hostname
- PRIVATE_IP - set to desired ip address
- BOX_NAME - set to desired box name (stored under Virtualbox VMs)
- BOX_MEMORY - set to desired memory (example uses 512mb)
- PROVISION - point to provisioning script (default is provision.sh, change if configuring your own)
- Edit provision.sh file settings under "MYSQL CONFIG", also name SQL to import the same and put under database folder
- MYSQLPASS - set MySQL root password
- MYSQLDATABASE - set name of MySQL database (be sure this name is the same as your SQL file under the /database/ folder)
- MYSQLWPUSER - set user for database to use for Wordpress configuration
- MYSQLWPUSERPW - set password for user to use for Wordpress configuration
- MYSQLWPIMPORT - set to yes if importing current database structure or no for new Wordpress setup
- DIGITALOCEAN_TOKEN - set to Digital Ocean token created in your account
- DIGITALOCEAN_REGION - set to your region, examples:(nyc3, br1, sfo1, ams4)
- DIGITALOCEAN_SIZE - set to desired box (512mb, 1g, 2g, 4g, 8g)
- Edit virtualhosts file
- Forces example.com to be www.example.com. Change as necessary.
server {
# Force WWW if not entered
listen 127.0.0.1:8080;
server_name example.com;
rewrite ^/(.*)$ http://www.example.com/$1 permanent;
}
- Sets domain to www.example.com and points the root to the /project/www/prod folder. Also sets names for the access log and error log. Change server_name, access_log name, and error_log name.
server {
# Prod
listen 127.0.0.1:8080;
server_name www.example.com;
root /project/www/prod;
access_log /var/log/nginx/www.example.com.access.log;
error_log /var/log/nginx/www.example.com.error.log;
include global/common.conf;
include global/wordpress.conf;
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
}
- Add custom domain to /etc/hosts file on Mac or C:\Windows\System32\Drivers\etc\hosts file on Windows and point to 192.168.31.15 or whatever you change the IP to.
- You can use Gas Mask (Mac) to edit your /etc/hosts file and easily swap between custom/original hosts file with the icon in the menu bar: Example:
192.168.31.15 example.com
192.168.31.15 www.example.com