First, look for the previously installed Discuz installation directory on the server
Copy to the Web installation directory, rename
cd/usr/local/src/
Cp-r upload/home/webser/
MV Upload bbs.lh2.com
Set User user group permissions for the Discuz forum installation directory
Chmod-r 755 bbs.lh2.com/
Chown-r www.www bbs.lh2.com/
Directly copy a previous forum configuration file, modify the domain name
CP bbs_lh.conf bbs_lh2.conf
Vim bbs_lh2.conf
server {
Listen 80;
server_name server IP;
Access_log/home/lnmp/nginx/logs/lh.log combined;
root/home/webser/bbs.lh2.com;
Index forum.php index.html index.htm index.php;
Create an old database name for the previous forum Bbs_lh_old
Then export the previous database and import it into bbs_lh_old.
Change the database configuration file, switch to this library, to ensure that the online forum business is not affected
MySQL [bbs_lh_old]> CREATE DATABASE bbs_lh_old;
Here continue to use the previous Forum database user name and password, set bbs_lh_old permissions
MySQL [bbs_lh_old]> Grant all on bbs_lh_old.* to [e-mail protected] identified by ' OldPassword ';
Before exporting the database of the forum
Mysqldump-uroot-p BBS_LH > Bbs.lh.sql
Import into the bbs_lh_old.
Mysql-uroot-p Bbs_lh_old < Bbs.lh.sql
Change the database configuration file, switch to bbs_lh_old this library, to ensure that the online forum business is not affected
cd/home/webser/bbs.lh.com/
Vim uc_server/data/config.inc.php
<?php
Define (' uc_dbhost ', ' localhost ');
Define (' Uc_dbuser ', ' oldusername ');
Define (' UC_DBPW ', ' OldPassword ');
Define (' Uc_dbname ', ' bbs_lh_old ');
Vim config/config_global.php
$_config = Array ();
----------------------------CONFIG DB-----------------------------//
$_config[' db ' [' 1 '] [' dbhost '] = ' localhost ';
$_config[' db ' [' 1 '] [' dbuser '] = ' oldusername ';
$_config[' db ' [' 1 '] [' dbpw '] = ' oldpassword ';
$_config[' db ' [' 1 '] [' dbname '] = ' bbs_lh_old ';
Vim config/config_ucenter.php
<?php
Define (' Uc_connect ', ' MySQL ');
Define (' uc_dbhost ', ' localhost ');
Define (' Uc_dbuser ', ' oldusername ');
Define (' UC_DBPW ', ' OldPassword ');
Define (' Uc_dbname ', ' bbs_lh_old ');
Now restart the nginx, PHP, MySQL service, test to see if the forum access is normal
Service Nginx Restart
Service mysqld Restart
Service PHP-FPM Restart
After the browser access to the forum test is normal, the following can be removed from the previous forum database
Create a new database with the same database name as before, set the new database user rights and password
MySQL [(None)]> drop database bbs_lh;
MySQL [(None)]> CREATE Database Bbs_lh;
MySQL [(None)]> grant all on bbs_lh.* to [e-mail protected] identified by ' OldPassword ';
Now you can go to the browser to enter the new forum bbs_lh2.conf corresponding domain name, install discuz Forum
Fill out some information in the Discuz forum graphical installation Interface
Database server: localhost
Database name: BBS_LH
Database user name: Oldusername
Database Password: OldPassword
New Forum Bbs.lh2.com access method: IP
Old Forum bbs.lh.com access method: Domain name
According to the needs of the Forum Administrator, import the relevant data and user information of the previous forum database to the new database
Then notify the Forum administrator, now to switch the new forum and the domain name of the old forum, it is recommended that he temporarily closed the site after his own configuration forum
Vim/home/lnmp/nginx/conf/vhost/bbs_lh_old.conf
server {
Listen 80;
server_name IP;
Cd/home/webser/bbs.lh_old.com
Vim config/config_ucenter.php
Define (' Uc_api ', ' http://IP/uc_server ');
Vim/home/lnmp/nginx/conf/vhost/bbs_lh.conf
server {
Listen 80;
server_name domain name;
Cd/home/webser/bbs.lh.com
Vim config/config_ucenter.php
Define (' Uc_api ', ' http://domain name/uc_server ');
Then notify the official website Developer Z, let him modify the configuration
Do not forget to find key sent to Z $bbs/uc_server/data/config.inc.php key
Because the online environment domain name resolution, has already looked for the CDN engineer to do, now the new forum domain name has not changed, does not need to change the domain name to parse
What needs to be done is to modify the contents of the backup script, the old forum data previously backed up, and now to back up the new forum data now
cd/home/backup/
Vim backup.sh
#!/bin/bash
Echo-e "\033[31;15m---------------------------\033[0m"
Echo-e "\033[31;1m Start running Blog database backup script: \033[0m"
Echo-e "\033[31;15m---------------------------\033[0m"
Db_user=root
db_pwd= ' db mysql password '
Db_name= ("Bbs_ld" "Bbs_lh" "Bbs_lh_old" "Bbs_zb" "BLOG_LH")
backup_path=/home/backup/db
Backup_date= ' DATE +%y%m%d-%h%m%s '
code_srcpath=/home/webser/
Code_destpath=/home/backup/code
Code_name= ("bbs.ld.com" "bbs.lh.com" "bbs.lh_old.com" "bbs.zb.com" "blog.lh.com")
#创建备份目录
if [!-e $BACKUP _path] | | [!-e $CODE _destpath];then
ECHO-E "\033[33m Create backup directory/home/backup......\033[0m"
/bin/mkdir-p $BACKUP _path $CODE _destpath >/dev/null 2>&1
ECHO-E "\033[33m backup directory/home/backup creation complete! \n\033[0m "
Fi
#备份博客数据库并删除
For backup_db in ${db_name[@]};d o
echo "Start backing up the database-$BACKUP _db ..."
/home/lnmp/mysql/bin/mysqldump-u$db_user-p$db_pwd $BACKUP _db > $BACKUP _path/$BACKUP _db-$BACKUP _date.sql
#echo $BACKUP _path/$BACKUP _db-$BACKUP _date.sql
ECHO-E "\033[33m$backup_db Library backup complete! \033[0m "
echo "--------------------"
Done
#/bin/find $BACKUP _path-type f-name "*.sql"-mtime +5 |xargs RM-RF
Echo-e "\033[31;15m---------------------------\033[0m"
Echo-e "\033[31;1m Start running Blog source backup script: \033[0m"
Echo-e "\033[31;15m---------------------------\033[0m"
#备份博客源码并删除
CD $CODE _srcpath
For Backup_code in ${code_name[@]};d o
echo "Start Backup source-$BACKUP _code ..."
#/bin/tar zcf $BACKUP _code-$BACKUP _date.tar.gz $BACKUP _code/
#/bin/mv $BACKUP _code-$BACKUP _date.tar.gz $CODE _destpath
/bin/cp-r $BACKUP _code $CODE _destpath/$BACKUP _code-$BACKUP _date.bak
ECHO-E "\033[33m$backup_code Source backup complete! \033[0m "
echo "--------------------"
Done
#/bin/find $CODE _destpath-type d-name "*.bak"-mtime +5 |xargs RM-RF
Detailed operations for the production Environment website Forum Migration