Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Vagrant
Search
Tom J Nowell
March 19, 2014
Technology
1
470
Vagrant
Using vagrant to host WordPress locally
Tom J Nowell
March 19, 2014
Tweet
Share
More Decks by Tom J Nowell
See All by Tom J Nowell
Using Blocks Outside The Editor
tarendai
0
890
Composer_and_WordPress__1_.pdf
tarendai
0
68
REST APIs for Absolute Beginners
tarendai
0
920
VVV 2
tarendai
0
710
WordCamp Europe 2016 - Handling Anxiety
tarendai
1
430
Escape From New York
tarendai
0
670
WP The Right Way
tarendai
0
1k
Code Deodorant 2014
tarendai
1
680
Adv WP CLI
tarendai
0
670
Other Decks in Technology
See All in Technology
LINE API Deep Dive Q1 2025: Unlocking New Possibilities
linedevth
1
160
LINEギフトのLINEミニアプリアクセシビリティ改善事例
lycorptech_jp
PRO
0
240
初めてのPostgreSQLメジャーバージョンアップ
kkato1
0
380
年末調整プロダクトの内部品質改善活動について
kaomi_wombat
0
200
Keynote - KCD Brazil - Platform Engineering on K8s (portuguese)
salaboy
0
120
SpannerとAurora DSQLの同時実行制御の違いに想いを馳せる
masakikato5
0
560
日本MySQLユーザ会ができるまで / making MyNA
tmtms
1
340
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
20k
Go の analysis パッケージで自作するリファクタリングツール
kworkdev
PRO
1
370
バックエンドエンジニアによるフロントエンドテスト拡充の具体的手法
kinosuke01
1
630
チームの性質によって変わる ADR との向き合い方と、生成 AI 時代のこれから / How to deal with ADR depends on the characteristics of the team
mh4gf
4
320
空が堕ち、大地が割れ、海が涸れた日~もしも愛用しているフレームワークが開発停止したら?~ #phperkaigi 2025
77web
2
990
Featured
See All Featured
Facilitating Awesome Meetings
lara
53
6.3k
Thoughts on Productivity
jonyablonski
69
4.5k
Site-Speed That Sticks
csswizardry
4
450
VelocityConf: Rendering Performance Case Studies
addyosmani
328
24k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
31
4.7k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
135
33k
Docker and Python
trallard
44
3.3k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
2.9k
Fontdeck: Realign not Redesign
paulrobertlloyd
83
5.4k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
102
18k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.5k
A Philosophy of Restraint
colly
203
16k
Transcript
Vagrant Virtual Machines + automation = win Tom J Nowell,
@tarendai, tomjn. com
• What is Vagrant • Installing Vagrant • Using Vagrant
• Moving to Vagrant
Installing Vagrant Install Virtualbox https://www.virtualbox. org/wiki/Downloads
Installing Vagrant
Installing Vagrant Install Vagrant http://vagrantup.com
Installing Vagrant
Installing Vagrant Install the Hosts Updater: $ vagrant plugin install
vagrant-hostsupdater $ vagrant plugin install vagrant-vbguest
Using Vagrant What now?
Using Vagrant Grab Varying Vagrant Vagrants
Using Vagrant VVV is now your web environment
Using Vagrant Open the VVV folder in the terminal and
type vagrant up --provision to start the server for the first time
Using Vagrant
Using Vagrant To stop the server: vagrant halt
Using Vagrant To start it again: vagrant up
Using Vagrant To destroy the server: vagrant destroy
Using Vagrant To login to the server: vagrant ssh
Using Vagrant To check if it’s running: vagrant status
Using Vagrant vagrant up # start vagrant halt # stop
vagrant destroy # destroy vagrant ssh # login vagrant status # is it up?
Using Vagrant This gets you: • Ubuntu Virtual Machine •
PHPMyAdmin • Nginx • WordPress Dev & stable • WP CLI • all listed at http://vvv/
Using Vagrant
Moving to Vagrant To add a site, go to the
www folder and create: • A subfolder for your site • a vvv-nginx.conf file • a vvv-hosts file
Moving to Vagrant vvv-nginx.conf contains an Nginx configuration file
Moving to Vagrant vvv-hosts is a hosts file with the
list of hosts to add
Example vvv-nginx.conf server { listen 80; listen 443 ssl; #
CHANGE THE DOMAINS BELOW AND SAVE server_name tomjn.com www.tomjn.com; root {vvv_path_to_folder}; include /etc/nginx/nginx-wp-common.conf; }
Example vvv-hosts tomjn.com www.tomjn.com
Moving to Vagrant When you’ve done that, put your sites
files in that folder, and re-provision the server: vagrant halt vagrant up --provision
Moving to Vagrant • All my sites are in MAMP
• I change files and FTP them up to see the changes • What about our existing sites? • We dont have the time to switch over
Moving to Vagrant vvv-init.sh Gets ran when vagrant provisions itself.
Lives with vvv-nginx.conf and vvv-hosts
Moving to Vagrant Example vvv-init.sh wp core download wp core
install --url=”etc.. wp plugin install wpseo wp plugin activate wpseo wp import content.xml
#!/bin/sh SUSER="alantaifirestar"; # SSH user SHOST="tomjn.com"; # remote server SDIR="/home/alantaifirestar/tomjn.com/";
# remote folder LDIR="/srv/www/tomjn.com" #local folder echo 'starting rsync' rsync -e "/usr/bin/ssh" --compress --stats --bwlimit=2000 -rlDHS $SUSER@$SHOST:$SDIR $LDIR echo 'finished rsync, grabbing database' WHOST=`cat $LDIR/wp-config.php | grep DB_HOST | cut -d \' -f 4`; # get the DB details WNAME=`cat $LDIR/wp-config.php | grep DB_NAME | cut -d \' -f 4`; WUSER=`cat $LDIR/wp-config.php | grep DB_USER | cut -d \' -f 4`; WPASS=`cat $LDIR/wp-config.php | grep DB_PASSWORD | cut -d \' -f 4`; ssh $SUSER@$SHOST "mysqldump -q -u $WUSER -h $WHOST -p$WPASS $WNAME | gzip -9 > backup. sql.gz" scp $SUSER@$SHOST:./backup.sql.gz . # copy all the files to backup server ssh $SUSER@$SHOST rm ./backup.sql.gz # delete files on db server gunzip -d backup.sql.gz # unzip it mysql -u root -e "CREATE DATABASE IF NOT EXISTS $WNAME" # create the database locally mysql -u root -e "GRANT ALL PRIVILEGES ON $WNAME.* To 'wp'@'localhost'" mysql -u wp -pwp $WNAME < backup.sql # pull in the DB dump sed -i "/DB_HOST/s/'[^']*'/'localhost'/2" wp-config.php # change wp-config.php values sed -i "/DB_USER/s/'[^']*'/'wp'/2" wp-config.php sed -i "/DB_PASSWORD/s/'[^']*'/'wp'/2" wp-config.php
Questions? Tom J Nowell @tarendai tomjn.com