WordPress migration

First, migration purposes

WordPress is an open source software that lets you create outstanding website, blog or application. Official website: https://cn.wordpress.org/download/, is the beginning WordPress will deploy a virtual machine locally, this disadvantage can not access other people, and he can not be accessed anytime, anywhere. So I want to migrate to WordPress on Amazon's cloud servers. Because before been deployed on virtual machines through WordPress, set more in line with the theme, but also on some of the details to be modified. If you re-deploy too much trouble, so you want to migrate local virtual machines to the cloud server up.

Second, build environment

Centos7 system installed in the cloud server, and install Apache, PHP, MySQL.
1, install Apache

yum install httpd   #安装httpd服务
systemctl start httpd       #启动web服务
systemctl enable httpd     #设置开机自启动
systemctl status httpd     #查看httpd服务状态
systemctl stop firewalld    关闭防火墙

2, install PHP

yum -y install epel-release

#获取PHP7.0的yum源
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

#安装PHP拓展
yum install php70w php70w-fpm php70w-cli php70w-common php70w-devel php70w-gd php70w-pdo php70w-mysql php70w-mbstring php70w-bcmath

安装PHP拓展后查看版本
php -v

systemctl start php-fpm.service   启动
systemctl stop php-fpm.service    停止
systemctl restart php-fpm.service   重启
systemctl reload php-fpm.service   重启修改配置

3, the installation MySQL

获取repo源
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

安装下载好的mysql-community-release-el7-5.noarch.rpm包
rpm -ivh mysql-community-release-el7-5.noarch.rpm

安装好mysql-community-release-el7-5.noarch.rpm包之后来安装MySQL
yum install mysql-community-server

systemctl start mysqld   启动MySQL服务
systemctl enable mysqld   开启启动MySQL服务
grep 'temporary password' /var/log/mysqld.log   查看数据库初始密码
update mysql.user set password=PASSWORD('yourpassword') where user='root';    修改MySQL root用户的密码
flush privileges;    更新权限
grant all privileges on *.* to root@'%' identified by '123';允许root用户远程连接数据库,连接密码:123
查看MySQL服务状态 

Third, the migration steps

The original virtual machine IP: 192.168.152.3
new virtual machine IP: 3.17.66.136

1, to copy the source code 192.168.152.3WordPress 3.17.66.136, may be compressed into a compressed, and then uploaded to the Apache root 3.17.66.136.

2, as the old configuration database environment configuration database is inconsistent with the new environment, it is necessary to modify wp-config.php configuration of the web root. Information is actual database name, user name and password to fill out. If the old environment to the new environment and database configuration consistent, ignore this step.

3, migrate the database. This step is the most important step, because all the settings from the old environment, the article, plug-ins, media libraries are stored on the MySQL database. Crap, now began to migrate the database.
3.1, export the database.

mysqldump -u root -p wordpress > wordpress.sql    在192.168.152.3上导出数据库
mysql -u root -p wordpress < "/root/wordpress.sql"   在3.17.66.136上导入数据库
PS:需要在3.17.66.136上新建wordpress数据库才能导入,否则会报错。

.2 modify the default WordPress URL. Because the old environment has been configured as the default URL: http: //192.168.152.3, so you need to modify the URL to http://3.17.66.136 in the new environment.

mysql -u root -p    进入MySQL数据库
use wordpress;    选择wordpress数据库
select * from wp_options limit 1;      查看默认URL配置

UPDATE wp_options SET option_value="http://3.17.66.136" WHERE option_name="siteurl";     将访问URL修改成新的域名或IP

This time to open the browser, enter the address of the new blog, see the familiar picture, nothing has changed, you're done.



Guess you like

Origin www.cnblogs.com/leeqizhi/p/11711881.html