DBNAME="wordpress" #要導(dǎo)入的數(shù)據(jù)庫名BACKUPSQL="/home/ksharpdabu.sql" #備份的sql文件絕對路徑OLD_WP-CONFIG="/home/wp-config.php" #以前保存到wp-config.php文件的絕對路徑#setting end?。EBROOT="/home/wwwroot" #網(wǎng)站根目錄http://www.dabu.info/ p=4329echo "###################################################################/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í)的功能就是讓用戶輸入任意鍵以繼續(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ù)庫,如果不存在http://www.dabu.info/ p=4329wget -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ù)庫到wordpress數(shù)據(jù)庫里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 settingUSERNAME="root" #數(shù)據(jù)庫用戶名PASSWORD="ksharpdabu.info" #數(shù)據(jù)庫密碼DBNAME="wordpress" #要導(dǎo)入的數(shù)據(jù)庫名BACKUPSQL="/home/ksharpdabu.sql" #備份的sql文件絕對路徑OLD_WP-CONFIG="/home/wp-config.php" #以前保存到wp-config.php文件的絕對路徑#setting end??!WEBROOT="/home/wwwroot" #網(wǎng)站根目錄http://www.dabu.info/ p=4329echo "###################################################################/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í)的功能就是讓用戶輸入任意鍵以繼續(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ù)庫,如果不存在http://www.dabu.info/ p=4329wget -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ù)庫到wordpress數(shù)據(jù)庫里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ù)庫,還備份了網(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那么就寫成:tar -zvxf all.tar.gz /home2.如果僅僅是重新安裝那么你就要添加一個(gè)刪除原先wordpress數(shù)據(jù)庫或表的命令:drop databasePHP教程