Apache网站数据迁移案例
日期:2017-06-13
环境:两台redhat 7.2最简化安装
servera 172.25.34.10
serverb 172.25.34.12
1.要求在servera上部署一个Apache环境,部署一个论坛
2.模拟迁移环境,将servera环境迁移到serverb上
-------------------------------------------------------------------------------------------------------------
1.安装部署apache环境
[root@servera ~]#yum install -y vim unzip bzip2 gzip net-tools apache php php-mysql mariadb-server
2.关闭selinux和防火墙
[root@servera ~]#setenforce 0
[root@servera ~]#systemctl stop firewalld
3.下载网站程序并解压
[root@servera ~]#wget http://172.25.254.254/content/items/MYSQL/00-pro/my-pro/discuz/Discuz_X3.0_SC_UTF8.zip
[root@servera ~]#unzip Discuz_X3.0_SC_UTF8.zip -d /var/www/html
4.设置网站目录权限
[root@servera ~]#cd /var/www/html
[root@servera html]#chown apache. /var/www/html -R
5.配置apache配置文件
1.)找到apache配置模板
[root@servera ~]#cat /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf
<VirtualHost *:@@Port@@>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "@@ServerRoot@@/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "/var/log/httpd/dummy-host2.example.com-error_log"
CustomLog "/var/log/httpd/dummy-host2.example.com-access_log" common
</VirtualHost>
2.)新建apache配置文件
[root@servera ~]#vim /etc/httpd/conf.d/bbs.hpoto.com.cnf
<VirtualHost *:80>
DocumentRoot "/var/www/html/upload"
ServerName bbs.hpoto.com
</VirtualHost>
6.启动mysql服务,并配置mysql密码,创建网站数据连接数据库用户,密码及权限
[root@servera ~]#systemctl start mysqld
[root@servera ~]#mysqladmin -uroot password 'uplooking'
[root@servera ~]#mysql -uroot -puplooking
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 25
Server version: 5.5.41-MariaDB MariaDB Server
Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> grant all on bbs.* to bbs@localhost identified by 'uplooking';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;
7.启动Apache服务器测试网站是否部署成功
[root@servera ~]#systemctl start httpd
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
迁移环境
迁移准备操作
1.关闭httpd,mariadb
[root@servera ~]#systemctl stop httpd
[root@servera ~]#systemctl stop mariadb
2.打包压缩迁移数据文件
[root@servera ~]#tar -zcf /tmp/Discuz.tar.gz /var/www/html/upload /etc/httpd/conf.d/bbs.hpoto.com.cnf /var/lib/mysql
[root@servera ~]#scp /tmp/Discuz.tar.gz root@172.25.34.11:/tmp/
---------------------------------------------------------------------------------
1.安装初始环境(要求:和servera环境一样)
[root@serverb ~]#yum install -y vim unzip bzip2 gzip net-tools apache php php-mysql mariadb-server
[root@serverb ~]#setenforce 0
[root@serverb ~]#systemctl stop firewalld
2.解压迁移数据
[root@serverb ~]#tar -xf /tmp/Discuz.tar.gz -C /
3.启动服务测试
[root@serverb ~]#systemctl start httpd
[root@serverb ~]#systemctl start mysqld
servera 172.25.34.10
serverb 172.25.34.12
1.要求在servera上部署一个Apache环境,部署一个论坛
2.模拟迁移环境,将servera环境迁移到serverb上
-------------------------------------------------------------------------------------------------------------
1.安装部署apache环境
[root@servera ~]#yum install -y vim unzip bzip2 gzip net-tools apache php php-mysql mariadb-server
2.关闭selinux和防火墙
[root@servera ~]#setenforce 0
[root@servera ~]#systemctl stop firewalld
3.下载网站程序并解压
[root@servera ~]#wget http://172.25.254.254/content/items/MYSQL/00-pro/my-pro/discuz/Discuz_X3.0_SC_UTF8.zip
[root@servera ~]#unzip Discuz_X3.0_SC_UTF8.zip -d /var/www/html
4.设置网站目录权限
[root@servera ~]#cd /var/www/html
[root@servera html]#chown apache. /var/www/html -R
5.配置apache配置文件
1.)找到apache配置模板
[root@servera ~]#cat /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf
<VirtualHost *:@@Port@@>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "@@ServerRoot@@/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "/var/log/httpd/dummy-host2.example.com-error_log"
CustomLog "/var/log/httpd/dummy-host2.example.com-access_log" common
</VirtualHost>
2.)新建apache配置文件
[root@servera ~]#vim /etc/httpd/conf.d/bbs.hpoto.com.cnf
<VirtualHost *:80>
DocumentRoot "/var/www/html/upload"
ServerName bbs.hpoto.com
</VirtualHost>
6.启动mysql服务,并配置mysql密码,创建网站数据连接数据库用户,密码及权限
[root@servera ~]#systemctl start mysqld
[root@servera ~]#mysqladmin -uroot password 'uplooking'
[root@servera ~]#mysql -uroot -puplooking
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 25
Server version: 5.5.41-MariaDB MariaDB Server
Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> grant all on bbs.* to bbs@localhost identified by 'uplooking';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;
7.启动Apache服务器测试网站是否部署成功
[root@servera ~]#systemctl start httpd
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
迁移环境
迁移准备操作
1.关闭httpd,mariadb
[root@servera ~]#systemctl stop httpd
[root@servera ~]#systemctl stop mariadb
2.打包压缩迁移数据文件
[root@servera ~]#tar -zcf /tmp/Discuz.tar.gz /var/www/html/upload /etc/httpd/conf.d/bbs.hpoto.com.cnf /var/lib/mysql
[root@servera ~]#scp /tmp/Discuz.tar.gz root@172.25.34.11:/tmp/
---------------------------------------------------------------------------------
1.安装初始环境(要求:和servera环境一样)
[root@serverb ~]#yum install -y vim unzip bzip2 gzip net-tools apache php php-mysql mariadb-server
[root@serverb ~]#setenforce 0
[root@serverb ~]#systemctl stop firewalld
2.解压迁移数据
[root@serverb ~]#tar -xf /tmp/Discuz.tar.gz -C /
3.启动服务测试
[root@serverb ~]#systemctl start httpd
[root@serverb ~]#systemctl start mysqld
上一篇:没有了
下一篇:没有了