发布于 2015-11-03 00:27:59 | 497 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

WordPress开源博客平台

WordPress是一种使用PHP语言开发的博客平台,用户可以在支持PHP和MySQL数据库的服务器上架设属于自己的网站。也可以把 WordPress当作一个内容管理系统(CMS)来使用。


这篇文章主要介绍了在Linux系统下一键重新安装WordPress的脚本示例,尤其适用于VPS服务器上进行操作,需要的朋友可以参考下

网站可能时不时的要迁移,或者误操作,数据库没了,所以,我为了省时间,写了个wordpress一键重新安装的脚本。

我这只是写个大概的。大家可以根据自己的需要修改脚本。

使用条件:

我这个脚本主要用在网站迁移的情况下,完全重新安装时候用的。也就是说,我这个操作只导入数据库等操作。那些wordpress的主题和插件等文件我并没有用在下面的脚本,需要的话,你可以自己改(下面会提到)。

准备以下文件:

  •     原来wordpress的配置文件wp-config.php
  •     原来的wordpress数据库备份文件
  •     系统安装了wget(大部分默认安装了)
#!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



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务