All sites on server will live in folder “~/sites”
ex) ~/sites/lustfulhealth-dev
Once capistrano = in place, these files will be symlinked.
~ = / {home} / {username}
Cap -T shows all capistrano commands
process = same for prod, staging and dev
If creating a site for staging, such as dev.example.com, first you must create the subdomain using cPanel or whatever is provided by hosting service
Go to domains and create a new subdomain and have the path be ~/public_html/{subdomain}
ex) dev.lustfulhealth.com == ~/public_html/dev
Create database using cPanel for subdomain
Fork / Clone WP-Capistrano Repo
### $ git clone
learn2reid/wp_capistrano.git ###
### $ git clone
Kronda/wp_capistrano.git ###
.git, .gitattributes, .git
9Wordpress Folder // Where all actual wordpress files are
Webroot Folder5 // Symbolically Linked Folder –all projects live in a folder called webroot
3) Link to Personal GitHub & remove other remotes
On github (or your version of SVN), make a new Repo
should be called your hostname
ex) lustfulhealth, wordcamp, locialnetwork
Grab the ssh code from GitHub
Note: to show removes do : git remote -v
Add new remote from GitHub
git remote add origin git@github… {COPIED SSH CODE}
git remote add origin
###
Create “local-config.php” – Get Wordpress Installed Locally
Open Folder in Sublime Text
NOTE: “local-config.php” holds all DB credentials
never put credentials in wp-config for security purposes
Create local-config.php in wordpress folder
Verify that local version works
should come up with 2013 wordpress theme
ADD WP MULTI CONFIG INSTEAD FOR MULTISTAGING
Set:Application, ‘project_name’ = #{PROJECT_NAME}
NO UNDERSCORES OR DASHES OR SPACES
set: local_path, "/home3/lustful1/sites/{app_root}
set: ssh_user, “{name youd use to log in server”
set: stage, “{leave at dev for most used stage}”
set: local_domain, “dev.locialnetwork.com”
DO NOT ADD
OR SLASH AFTER ###
Go into main deploy stage – dev.rb
IMPORTANT: ADD set: local_domain, ‘dev.site.dev’ or ‘staging.site.dev’ for each site
Server: All sites live in:
/{home}/{username}/sites/#{application}-#{stage}
ex) /home3/lustful1/sites/lustfulhealth-dev
### ###
WP-CLI settings for any stage.rb file
set :wp, “cd #{current_path}/#{app_root} ; /home3/lustful1/.wp-cli/bin/wp”
#(Should be the full path to the wp command on your server)
git commit -m “Updated Config FIles ”
### ###
BRANCHING: 5Branches should match stages
Development => dev —- Staging => staging
Make new dev branch & switch to it
Push dev branch up to Github
different stages for each stage of development
Git naturally creates master brnace
develop5 in the development5 branch
then merge to staging or prod
Can delete Master brance & jstu pull form stage-specific branches
### ###
role:db, “kronda.com” // usually same as web server
### ###
add to config file!!!!!!!!!! SUPER IMPORTANT (esp if you get error: permession denied (publickey)
Host tykaconcepts.com9ForwardAgent yes
Dependencies will fail @ first b/c folders ≠ exist yet
run cap check again after just in case
ignore change group error apache
If all is good to go, deploy!
Look for {project_name}-dev
9current // always points to latest release of site
releases 5// History of releases
WHERE LOCAL-CONFIG.php exists for SERVER VERSION
cap dev deploy:create_settings_php
Puts local-config.php in shared/default folder on server
Open local-config on server and fill in server DB details for that stage.
sftp://lustfulhealth.com//home3/lustful1/sites/lustfulhealth-staging/shared/default/local-config.php
13) Add/Import DB into Server
Get sql dump from local version
sequel / phpMyAdmin / Navicat / WP Migrate Pro Plugin
DO SEARCH & REPLACE FOR URLS & PATH
Import to Server DB –> phpMyAdmin
14) Push all local content ≠ in repo upto server
To push all local content not in repo up to server
cap dev files:push // in ~/Sites/{project}/wordpress
DOESNT PUSH PLUGINS OR THEMES
15) Symlink - Server Config (Delete original Subdomain & Symlink)
cd ~/sites/current/wordpress && pwd
copy path5 and go back to public_html
DELETE Orginal SUBDomain in ~/public_html
ex) rm -rf wordcamp.karveldigital.com/
Symlink subdomain to sites/project folder
ln -s /{home}/{username}/sites/{project}-{stage}/current/wordpress SPACE /{home}/{username}/public_html/{subdomain}
ex) ln -s /home3/lustful1/sites/lustfulhealth-dev/current/wordpress /home3/lustful1/lustful1/public_html/dev
ll to show that it’s symlinked
## ##
SITE SHOULD BE LIVE AND WORKING AT THIS POINT
First Time
a) Create DB folder in Root
### ###
b) #FixMe Search in CapFile
### ###
c) Export DB using WP-CLI
cd ~/Sites/{project}/wordpress
wp db export ../db/default_dev.sql
LOCAL: check in ~/Sites/wordcamp/db to see if it worked, default_dev.sql should exist
wp db export #{filename} –url=#{stage}.lustfulhealth.dev
sed -e ‘s/dev.lustfulhealth.com/staging.lustfulhealth.dev/g’ -i .bak default_dev.sql
d) Push Local DB upto Dev Server
e) PULL DB DOWN - db:down & db:pull
2 options: db:down or db:pull
db:down:5 pulls down backup and places it in db folder
db:pull:5 pulls down db and replaces local copy with what you pulled /// I EDITED THIS ONE
both do search and replaces
≠ First Time
cap {stage} deploy:check
2) DB: 5wped & wpes – db:push
wp db export ../db/default_{stage}.sql –url=dev.lustfulhealth.dev’
must include –url=dev.lustfulhealth.dev’ if used local-config.php with case switches
wped = ‘wp db export ../db/default_dev.sql –url=dev.lustfulhealth.dev’
wpes = ‘wp db export ../db/default_staging.sql –url=staging.lustfulhealth.dev’
Configure WP-CLI on Server
Path to WP-CLI in dev = /{home}/{username}/.wp-cli/bin/wp
must run with PHP-CLI !!!
GTID + mySQL Errors – –set-gtid-purged=OFF
mySQLdump = .wp-cli/vendor/wp-cli/wp-cli/php/commands/db.php
If have GTID error add: –set-gtid-purged=OFF after mysqldump command
Line 123: self::run( Utils\esc_cmd( ‘mysqldump 9–set-gtid-purged=OFF %s’, DB_NAME ), array(
GIT – Commit Line ending errors
find /core/sites/all/modules -type f -exec dos2unix {} +
Capistrano – Could not parse object ’77514601ab8705e36f26270098b2aa268d9a7899′The easy solution is to go to the server to which you are attempting to deploy and delete the “cached-copy” directory under the “shared” directory.
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
### ###
create .htaccess and .htpasswd files in ~/sites/{project}-{stage}/shared
.htaccess in ~/sites/#{project-name}-dev/shared/.htaccess
# Password Protect AuthType Basic AuthName “Development Area: Locial Network Only” AuthUserFile /home3/lustful1/sites/lustfulhealth-dev/shared/default/.htpasswd require valid-user
.htpasswd ~/sites/#{project-name}-dev/shared/default/.htpasswd
username:<encrypted key from
####
92) LOCAL CAPFILE (ADD TO CAPFILE in SYMLINK SECTION)
run “ln -nfs #{deploy_to}/#{shared_dir}/#{domain}/.htpasswd #{release_path}/#{app_root}/.htpasswd”
run “ln -nfs #{deploy_to}/#{shared_dir}/#{domain}/.htaccess #{release_path}/#{app_root}/.htaccess”
93) GIT COMMIT & REDEPLOY
See codebox for .htaccess error docs in apache
basically in .htaccess for that stage folder
ErrorDocument code /directory/filename.ext
## ##