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"#!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教程