這篇文章給大家介紹怎么在Linux系統(tǒng)中重新安裝WordPress,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。
準(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ù)用戶名 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í)的功能就是讓用戶輸入任意鍵以繼續(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ù)用戶名 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í)的功能就是讓用戶輸入任意鍵以繼續(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
那么就寫成:
tar -zvxf all.tar.gz /home
2.如果僅僅是重新安裝
那么你就要添加一個(gè)刪除原先wordpress數(shù)據(jù)庫(kù)或表的命令:
drop database
關(guān)于怎么在Linux系統(tǒng)中重新安裝WordPress就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。