The next key to the Linux system reinstall WordPress Script Example _php tips

Source: Internet
Author: User
Tags vps wordpress database

Site may be migrated from time to time, or wrong operation, the database is gone, so, I in order to Time-saving, wrote a wordpress one-click Reinstall Script.

I'm just writing a ballpark figure. You can modify the script according to your own needs.

Conditions of Use:

This script is mainly used in the case of Web site migration, when fully reinstalled. In other words, I only import the database operation. WordPress themes and Plug-ins and other files I do not use the following script, if necessary, you can change it (mentioned below).

Prepare the following documents:

    • The original WordPress configuration file wp-config.php
    • Original WordPress Database backup file
    • The system has wget installed (most of which are installed by default)
#!bin/sh #vps WordPress One-click Reinstall Script #global Setting username= "root" #数据库用户名 password= "Ksharpdabu.info" #数据库密码 dbname= "word Press "#要导入的数据库名 backupsql="/home/ksharpdabu.sql "#备份的sql文件绝对路径 old_wp-config="/home/wp-config.php "#以前保存到wp-co

Absolute path to nfig.php file #setting end!! webroot= "/home/wwwroot" #网站根目录http://www.dabu.info/?p=4329 echo "################################################ ###################\n "echo" Please backup your website data when your run this shell script!!!! \ n "echo" Please backup your website data when your run this shell script!!!! \ n "echo" Please backup your website data when your run this shell script!!!! \ n "echo" ###################################################################\n "Get_char" () #这一段的代码其实的功能就是让用户输入任意键 To continue executing the script, it is a common code snippet {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 The database if not EXISTS ${dbname} "Mysql-u${username}-p${password}-E" ${create_db} "#创建名为wordpress的数据库 if there is no 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_w P-config} ${webroot} #将原先的wordpress的配置文件wp-config.php to the site root Mysql-u${username}-p${password} ${dbname} <${
Backupsql} #导入你备份的数据库到wordpress数据库里 echo "###################################################################\n" echo "Please view your blog to check the success or failure.\n" echo "View I blog:http://www.dabu.info/if you have questi on!! \ n "echo" ###################################################################\n "#!bin/sh #vps WordPress One-click Reinstall Script # Global setting Username= "root" #数据库用户名 password= "Ksharpdabu.info" #数据库密码 dbname= "WordPress" #要导入的数据库名 backupsql= " Home/ksharpdabu.sql "#备份的sql文件绝对路径 old_wp-config="/home/wp-config.php "#以前保存到wp the absolute path of the-config.php file #setting end!! webroot= "/home/wwwroot" #网站根目录http://www.dabu.info/?p=4329 echo "################################################ ###################\n "echo" Please backup your website data when your run this shell script!!!! \ n "echo" Please backup your website data when your run this shell script!!!! \ n "echo" Please backup your website data when your run this shell script!!!! \ n "echo" ###################################################################\n "Get_char" () #这一段的代码其实的功能就是让用户输入任意键 To continue executing the script, it is a common code snippet {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 The database if not EXISTS ${dbname} "Mysql-u${username}-p${password}-E" ${create_db} "#创建名为wordpress的数据库 if there is no http://www . dabu.info/?p=4329 wget-c http: #cn. Wordpress.org/wordpress-3.7.1-zh_cn.zip #下载wordpress网Station program Unzip wordpress-3.7.1-zh_cn.zip #解压wordpress程序 CD WordPress #切换到解压后的wordpress目录 CP./* ${webroot} #将网站程序复制到网站根目录 \ CP ${old_wp-config} ${webroot} #将原先的wordpress的配置文件wp-config.php to site root mysql-u${username}-p${password} ${dbname} <${backupsql} #导入你备份的数据库到wordpress数据库里 echo "################################################################# ##\n "echo" Please view your blog to check the success or failure.\n "echo" View I blog:http://www.dabu.info/if you have question!!

 \ n "echo" ###################################################################\n "

Ps: Modify the script as needed

1. If you not only back up the database, but also back up the Web site Plug-ins and other documents, then you will directly:

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  # Download wordpress Web program
unzip wordpress-3.7.1-zh_cn.zip  #解压wordpress程序
cd WordPress  # Switch to the unpacked WordPress directory
CP./*  /home/wwwroot/  #将网站程序复制到网站根目录
\cp ${old_wp-config} ${webroot}

Delete, replace all backup files of the site to extract the Copy command on it.

Suppose I've backed up the entire/wwwroot directory for all.tar.gz

Then it's written:

TAR-ZVXF all.tar.gz  /home

2. If you are simply reinstalling

Then you need to add a command to delete the original WordPress database or table:

Drop database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.