Wordpress Auto Deploy
自动化(脚本)部署
目录:
Wordpress 本地自动初始化
Wordpress 线上初始化(本地至线上)
Wordpress 线上自动更新
Wordpress 本地自动初始化
Nginx File
Shell
Wordpress Bedrock
Common wordpress Config - application
Composer update
Shell
Create Database
Shell
Env
local
Local Host
#!/bin/bash
#Variable
rootdir=
nginxfile=
databasename=
pwd=
#Step 1: Nginx file
sudo cp /var/www/$rootdir/$nginxfile /etc/nginx/sites-available
sudo ln -s /etc/nginx/sites-available/$nginxfile /etc/nginx/sites-enabled
sudo service nginx restart
#Step 2: Wordpress Bedrock
sudo cp -r /var/www/wordpress/* /var/www/$rootdir/
sudo cp -r /var/www/wordpress/.gitignore /var/www/$rootdir/
cd /var/www/$rootdir
sudo composer update
#Step 3:Create database
mysql -u root -p$pwd -e "create database $databasename"
#Setp 4: Cp .evn
sudo cp /var/www/wordpress/.env.example /var/www/$rootdir/.env
Final:
execute shell script
VIM Nginx file
VIM shell script
edit /etc/hosts
vim .env
Wordpress 线上首次部署
Nginx
Git clone
Composer Update
upload File
Create Database
export database
import Database
env file
#!/bin/bash
#Variable
rootdir=
nginxfile=
databasename=
pwd=
server=
#Step 1: Nginx file
scp ./$nginxfile $server:/etc/nginx/sites-available
ssh $server "ln -s /etc/nginx/sites-available/$nginxfile /etc/nginx/sites-enabled"
service nginx restart
#Step 2: Git Clone And Composer Update
ssh $server "cd /var/www; git clone git@github.com:xlcoder/deploytest.git"
ssh $server "cd /var/www/$rootdir; composer update"
#Step 3:Create database
ssh $server "mysql -u root -p$pwd -e \"create database $databasename\""
#Step 4:Evn file
scp ./.env.online $server:/var/www/$rootdir
ssh $server "cd /var/www/$rootdir; mv .env.online .env"
#Step 5:Database
ssh localphp7 "cd /var/www/$rootdir; mysqldump -u root -p123456abc $databasename > $databasename\_init\.sql"
scp ./$databasename\_init.sql $server:/tmp
ssh $server "cd /tmp; mysql -u root -p$pwd $databasename < $databasename\_init\.sql"
Final:
dns record
cp .env.online
git repoestiory
Bash Script
vim nginx file
vim git
Wordpress 线上持续更新
uploads
git pull
dabases
import
export
#!/bin/bash
#Variable
rootdir=
nginxfile=
databasename=
pwd=
server=
#Setp 1:Rsync Upload
rsync --ignore-existing -vzrh ./web/app/uploads $server:/var/www/$rootdir/web/app/
#Step 2: Git Clone And Composer Update
ssh $server "cd /var/www/$rootdir; git pull"
#Step 3:Database
ssh localphp7 "cd /var/www/$rootdir; mysqldump -u root -p123456abc $databasename > $databasename\_update\.sql"
scp ./$databasename\_update.sql $server:/tmp
ssh $server "cd /tmp; mysql -u root -p$pwd $databasename < $databasename\_update\.sql"