网站可能时不时的要迁徙,或许误操作,数据库没了,所以,我为了省工夫,写了个wordpress一键从新装置的脚本。
我这只是写个大略的。大家能够依据本人的需求修正脚本。
应用条件:
我这个脚本次要用在网站迁徙的状况下,齐全从新装置时分用的。也就是说,我这个操作只导入数据库等操作。那些wordpress的主题和插件等文件我并没有用在上面的脚本,需求的话,你能够本人改(上面会提到)。
预备以下文件:
#!bin/sh
#vps wordpress一键从新装置脚本
#global setting
USERNAME="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=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() #这一段的代码其实的性能就是让用户输出恣意键以持续执行脚本,是罕用的代码段
{
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=4329
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 ./* ${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 setting
USERNAME="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=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() #这一段的代码其实的性能就是让用户输出恣意键以持续执行脚本,是罕用的代码段
{
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=4329
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 ./* ${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 /home
2.假如仅仅是从新装置
那么你就要增加一个删除原先wordpress数据库或表的命令:
drop database
以上就是安达网络工作室关于《在Linux系统下一键重新安装WordPress的脚本示例》的一些看法。更多内容请查看本栏目更多内容!
get_permalink()(获取文章或页面链接) get_permalink() 用来依据固定衔接前往文章或许页面的链接。在获取...
locate_template() 用来检索存在的优先级最高的模板文件,还能间接加载模板文件。 locate_template() 函数检...
本文实例讲述了WordPress完成搜寻后果只有一篇文章时主动跳转到文章的办法。分享给大家供大家参考。详细剖析...
wp_title 函数在 WordPress 中是用来显示文章、页面、分类等等等等题目的一个函数,但在首页索引,该函数将...
穆童博客应用的是Wordpress顺序,上次在改换了效劳器之后不知为何一切新评论的IP地址都显示为127.0.0.1。刚...
本文实例讲述了WordPress站点呈现404谬误时邮件告诉治理员的办法。分享给大家供大家参考。详细剖析如下: 这...