在Linux系統(tǒng)下一鍵重新安裝WordPress的腳本示例
網(wǎng)站可能時(shí)不時(shí)的要遷移,或者誤操作,數(shù)據(jù)庫(kù)沒(méi)了,所以,我為了省時(shí)間,寫(xiě)了個(gè)wordpress一鍵重新安裝的腳本。
我這只是寫(xiě)個(gè)大概的。大家可以根據(jù)自己的需要修改腳本。
使用條件:
我這個(gè)腳本主要用在網(wǎng)站遷移的情況下,完全重新安裝時(shí)候用的。也就是說(shuō),我這個(gè)操作只導(dǎo)入數(shù)據(jù)庫(kù)等操作。那些wordpress的主題和插件等文件我并沒(méi)有用在下面的腳本,需要的話(huà),你可以自己改(下面會(huì)提到)。
準(zhǔn)備以下文件:
- 原來(lái)wordpress的配置文件wp-config.php
- 原來(lái)的wordpress數(shù)據(jù)庫(kù)備份文件
- 系統(tǒng)安裝了wget(大部分默認(rèn)安裝了)
#!bin/sh
#vps wordpress一鍵重新安裝腳本
#global setting
USERNAME="root" #數(shù)據(jù)庫(kù)用戶(hù)名
PASSWORD="ksharpdabu.info" #數(shù)據(jù)庫(kù)密碼
DBNAME="wordpress" #要導(dǎo)入的數(shù)據(jù)庫(kù)名
BACKUPSQL="/home/ksharpdabu.sql" #備份的sql文件絕對(duì)路徑
OLD_WP-CONFIG="/home/wp-config.php" #以前保存到wp-config.php文件的絕對(duì)路徑
#setting end?。?
WEBROOT="/home/wwwroot" #網(wǎng)站根目錄http://www.dabu.info/?p=4329
echo "###################################################################\n"
echo "please backup your website data when you run this shell script!!!!\n"
echo "please backup your website data when you run this shell script!!!!\n"
echo "please backup your website data when you run this shell script!!!!\n"
echo "###################################################################\n"
get_char() #這一段的代碼其實(shí)的功能就是讓用戶(hù)輸入任意鍵以繼續(xù)執(zhí)行腳本,是常用的代碼段
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo ""
echo "Press any key to start..."
char=`get_char`
create_db="create database IF NOT EXISTS ${DBNAME}"
mysql -u${USERNAME} -p${PASSWORD} -e "${create_db}" #創(chuàng)建名為wordpress的數(shù)據(jù)庫(kù),如果不存在http://www.dabu.info/?p=4329
wget -c http:#cn.wordpress.org/wordpress-3.7.1-zh_CN.zip #下載wordpress網(wǎng)站程序
unzip wordpress-3.7.1-zh_CN.zip #解壓wordpress程序
cd wordpress #切換到解壓后的wordpress目錄
cp ./* ${WEBROOT} #將網(wǎng)站程序復(fù)制到網(wǎng)站根目錄
\cp ${OLD_WP-CONFIG} ${WEBROOT} #將原先的wordpress的配置文件wp-config.php放到網(wǎng)站根目錄
mysql -u${USERNAME} -p${PASSWORD} ${DBNAME} <${BACKUPSQL} #導(dǎo)入你備份的數(shù)據(jù)庫(kù)到wordpress數(shù)據(jù)庫(kù)里
echo "###################################################################\n"
echo "please view you blog to check the success or failure.\n"
echo "view my blog:http://www.dabu.info/ if you have question!!\n"
echo "###################################################################\n"
#!bin/sh
#vps wordpress一鍵重新安裝腳本
#global setting
USERNAME="root" #數(shù)據(jù)庫(kù)用戶(hù)名
PASSWORD="ksharpdabu.info" #數(shù)據(jù)庫(kù)密碼
DBNAME="wordpress" #要導(dǎo)入的數(shù)據(jù)庫(kù)名
BACKUPSQL="/home/ksharpdabu.sql" #備份的sql文件絕對(duì)路徑
OLD_WP-CONFIG="/home/wp-config.php" #以前保存到wp-config.php文件的絕對(duì)路徑
#setting end??!
WEBROOT="/home/wwwroot" #網(wǎng)站根目錄http://www.dabu.info/?p=4329
echo "###################################################################\n"
echo "please backup your website data when you run this shell script!!!!\n"
echo "please backup your website data when you run this shell script!!!!\n"
echo "please backup your website data when you run this shell script!!!!\n"
echo "###################################################################\n"
get_char() #這一段的代碼其實(shí)的功能就是讓用戶(hù)輸入任意鍵以繼續(xù)執(zhí)行腳本,是常用的代碼段
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo ""
echo "Press any key to start..."
char=`get_char`
create_db="create database IF NOT EXISTS ${DBNAME}"
mysql -u${USERNAME} -p${PASSWORD} -e "${create_db}" #創(chuàng)建名為wordpress的數(shù)據(jù)庫(kù),如果不存在http://www.dabu.info/?p=4329
wget -c http:#cn.wordpress.org/wordpress-3.7.1-zh_CN.zip #下載wordpress網(wǎng)站程序
unzip wordpress-3.7.1-zh_CN.zip #解壓wordpress程序
cd wordpress #切換到解壓后的wordpress目錄
cp ./* ${WEBROOT} #將網(wǎng)站程序復(fù)制到網(wǎng)站根目錄
\cp ${OLD_WP-CONFIG} ${WEBROOT} #將原先的wordpress的配置文件wp-config.php放到網(wǎng)站根目錄
mysql -u${USERNAME} -p${PASSWORD} ${DBNAME} <${BACKUPSQL} #導(dǎo)入你備份的數(shù)據(jù)庫(kù)到wordpress數(shù)據(jù)庫(kù)里
echo "###################################################################\n"
echo "please view you blog to check the success or failure.\n"
echo "view my blog:http://www.dabu.info/ if you have question!!\n"
echo "###################################################################\n"
Ps:根據(jù)需要修改腳本情況
1.如果你不但備份了數(shù)據(jù)庫(kù),還備份了網(wǎng)站的插件等文件,那么,你就直接將:
wget -c http:#cn.wordpress.org/wordpress-3.7.1-zh_CN.zip #下載wordpress網(wǎng)站程序
unzip wordpress-3.7.1-zh_CN.zip #解壓wordpress程序
cd wordpress #切換到解壓后的wordpress目錄
cp ./* /home/wwwroot/ #將網(wǎng)站程序復(fù)制到網(wǎng)站根目錄
\cp ${OLD_WP-CONFIG} ${WEBROOT}
wget -c http:#cn.wordpress.org/wordpress-3.7.1-zh_CN.zip #下載wordpress網(wǎng)站程序
unzip wordpress-3.7.1-zh_CN.zip #解壓wordpress程序
cd wordpress #切換到解壓后的wordpress目錄
cp ./* /home/wwwroot/ #將網(wǎng)站程序復(fù)制到網(wǎng)站根目錄
\cp ${OLD_WP-CONFIG} ${WEBROOT}
刪除,換成將網(wǎng)站所有備份文件的解壓復(fù)制命令就可以了。
假設(shè)我整個(gè)我備份了/wwwroot目錄為all.tar.gz
那么就寫(xiě)成:
tar -zvxf all.tar.gz /home
2.如果僅僅是重新安裝
那么你就要添加一個(gè)刪除原先wordpress數(shù)據(jù)庫(kù)或表的命令:
drop database
相關(guān)文章
php通過(guò)curl方式實(shí)現(xiàn)發(fā)送接收xml數(shù)據(jù)
這篇文章主要為大家詳細(xì)介紹了php如何通過(guò)curl方式實(shí)現(xiàn)發(fā)送接收xml數(shù)據(jù),文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2023-11-11
在CentOS上搭建LAMP+vsftpd環(huán)境的簡(jiǎn)單指南
這篇文章主要介紹了在CentOS上搭建LAMP+vsftpd環(huán)境的簡(jiǎn)單指南,這也是當(dāng)下服務(wù)器的最流行配置方案之一,需要的朋友可以參考下2015-08-08
php基礎(chǔ)知識(shí):類(lèi)與對(duì)象(5) static
php基礎(chǔ)知識(shí):類(lèi)與對(duì)象(5) static...2006-12-12
淺談htmlentities 、htmlspecialchars、addslashes的使用方法
下面小編就為大家?guī)?lái)一篇淺談htmlentities 、htmlspecialchars、addslashes的使用方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-12-12
PHP實(shí)現(xiàn)逐行刪除文件右側(cè)空格的方法
這篇文章主要介紹了PHP實(shí)現(xiàn)逐行刪除文件右側(cè)空格的方法,涉及php針對(duì)文件的打開(kāi)、逐行讀取、rtrim函數(shù)刪除右側(cè)空格及文件保存等技巧,需要的朋友可以參考下2015-12-12
php設(shè)計(jì)模式 FlyWeight (享元模式)
運(yùn)用享元技術(shù)有效的支持大量細(xì)粒度的對(duì)象,需要的朋友可以參考下。2011-06-06
整理的一些實(shí)用WordPress后臺(tái)MySQL操作命令
WordPress將其所有信息片段(包括文章、頁(yè)面、評(píng)論、博客鏈接、插件設(shè)置等)存儲(chǔ)在MySQL數(shù)據(jù)庫(kù)中。 雖然WordPress用戶(hù)可以通過(guò)網(wǎng)站后臺(tái)編輯控制以上信息片段2013-01-01

