search
Homephp教程php手册在Linux系统下一键重新安装WordPress的脚本示例

这篇文章主要介绍了在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" #网站根目录?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的数据库,如果不存在?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} /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的数据库,如果不存在?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}

    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

    Statement
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    AI Hentai Generator

    AI Hentai Generator

    Generate AI Hentai for free.

    Hot Article

    R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
    3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. Best Graphic Settings
    3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. How to Fix Audio if You Can't Hear Anyone
    4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    WWE 2K25: How To Unlock Everything In MyRise
    1 months agoBy尊渡假赌尊渡假赌尊渡假赌

    Hot Tools

    SecLists

    SecLists

    SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

    SublimeText3 Linux new version

    SublimeText3 Linux new version

    SublimeText3 Linux latest version

    Atom editor mac version download

    Atom editor mac version download

    The most popular open source editor

    MinGW - Minimalist GNU for Windows

    MinGW - Minimalist GNU for Windows

    This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)