DBNAME="wordpress" #要導入的數據庫名BACKUPSQL="/home/ksharpdabu.sql" #備份的sql文件絕對路徑OLD_WP-CONFIG="/home/wp-config.php" #以前保存到wp-config.php文件的絕對路徑#setting end?。EBROOT="/home/wwwroot" #網站根目錄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() #這一段的代碼其實的功能就是讓用戶輸入任意鍵以繼續執行腳本,是常用的代碼段 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}" #創建名為wordpress的數據庫,如果不存在http://www.dabu.info/ p=4329wget -c http:#cn.wordpress.org/wordpress-3.7.1-zh_CN.zip #下載wordpress網站程序unzip wordpress-3.7.1-zh_CN.zip #解壓wordpress程序cd wordpress #切換到解壓后的wordpress目錄cp ./* ${WEBROOT} #將網站程序復制到網站根目錄/cp ${OLD_WP-CONFIG} ${WEBROOT} #將原先的wordpress的配置文件wp-config.php放到網站根目錄mysql -u${USERNAME} -p${PASSWORD} ${DBNAME} ${BACKUPSQL} #導入你備份的數據庫到wordpress數據庫里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" #數據庫用戶名PASSWORD="ksharpdabu.info" #數據庫密碼DBNAME="wordpress" #要導入的數據庫名BACKUPSQL="/home/ksharpdabu.sql" #備份的sql文件絕對路徑OLD_WP-CONFIG="/home/wp-config.php" #以前保存到wp-config.php文件的絕對路徑#setting end!!WEBROOT="/home/wwwroot" #網站根目錄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() #這一段的代碼其實的功能就是讓用戶輸入任意鍵以繼續執行腳本,是常用的代碼段 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}" #創建名為wordpress的數據庫,如果不存在http://www.dabu.info/ p=4329wget -c http:#cn.wordpress.org/wordpress-3.7.1-zh_CN.zip #下載wordpress網站程序unzip wordpress-3.7.1-zh_CN.zip #解壓wordpress程序cd wordpress #切換到解壓后的wordpress目錄cp ./* ${WEBROOT} #將網站程序復制到網站根目錄/cp ${OLD_WP-CONFIG} ${WEBROOT} #將原先的wordpress的配置文件wp-config.php放到網站根目錄mysql -u${USERNAME} -p${PASSWORD} ${DBNAME} ${BACKUPSQL} #導入你備份的數據庫到wordpress數據庫里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:根據需要修改腳本情況1.如果你不但備份了數據庫,還備份了網站的插件等文件,那么,你就直接將: wget -c http:#cn.wordpress.org/wordpress-3.7.1-zh_CN.zip #下載wordpress網站程序unzip wordpress-3.7.1-zh_CN.zip #解壓wordpress程序cd wordpress #切換到解壓后的wordpress目錄cp ./* /home/wwwroot/ #將網站程序復制到網站根目錄/cp ${OLD_WP-CONFIG} ${WEBROOT}wget -c http:#cn.wordpress.org/wordpress-3.7.1-zh_CN.zip #下載wordpress網站程序unzip wordpress-3.7.1-zh_CN.zip #解壓wordpress程序cd wordpress #切換到解壓后的wordpress目錄cp ./* /home/wwwroot/ #將網站程序復制到網站根目錄/cp ${OLD_WP-CONFIG} ${WEBROOT}刪除,換成將網站所有備份文件的解壓復制命令就可以了。假設我整個我備份了/wwwroot目錄為all.tar.gz那么就寫成:tar -zvxf all.tar.gz /home2.如果僅僅是重新安裝那么你就要添加一個刪除原先wordpress數據庫或表的命令:drop databasePHP教程