怎么在Linux系统中重新安装WordPress

发布时间:2021-03-02 17:01:38 作者:Leah
来源:亿速云 阅读:334

这篇文章给大家介绍怎么在Linux系统中重新安装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就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

推荐阅读:
  1. 怎么在docker中安装wordpress
  2. 怎么在Ubuntu中重新安装mysql

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

linux wordpress

上一篇:如何在Python中安装pandas模块

下一篇:怎么在php项目中调用百度UEditor

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》