一,博客搭建
1、确认环境
[root@web02 ~]# netstat -lntup|egrep "80|3306|9000"
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 12214/php-fpm: mast
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 12420/nginx: master
tcp6 0 0 :::3306 :::* LISTEN 7285/mysqld
2、下载上传开源BLOG,解压,权限
[root@web02 ~]# cd /server/tools/
[root@web02 /server/tools]# rz -y
rz waiting to receive.
[root@web02 /server/tools]# ls
libiconv-1.16 nginx-1.16.0 php-7.3.5.tar.gz
libiconv-1.16.tar.gz nginx-1.16.0.tar.gz wordpress-5.1.1.zip
mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz php-7.3.5
[root@web02 /server/tools]# unzip wordpress-5.1.1.zip
在[root@web02 /server/tools]# /application/nginx/html/下创建,workdpress
[root@web02 /server/tools]# mv wordpress/* /application/nginx/html/workdpress
给/application/nginx/html/workdpress 权限
[root@web02 /server/tools]# chown -R nginx.nginx /application/nginx/html/workdpress/ (暂时性)
[root@web02 /server/tools]# ls -ld /application/nginx/html/blog/
drwxr-xr-x 5 nginx nginx 4096 5月 7 09:14 /application/nginx/html/blog/
3,设置nginx 配置文件
[root@web02 /application/nginx/conf]#cat nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name blog.etiantian.org;
root html/wordpress;
index index.php index.html index.htm;
}
location ~ .*\.(php|php5)?$ {
root html/wordpress;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
4,[root@web02 /application/nginx/html/wordpress]#cp wp-config-sample.php wp-config.php
wp-config.php的主要配置
[root@web02 /application/nginx/html/wordpress]#cat wp-config.php
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );
/** MySQL database username */
define( 'DB_USER', 'root' );
/** MySQL database password */
define( 'DB_PASSWORD', 'oldboy123' );
/** MySQL hostname */
define( 'DB_HOST', '172.16.1.51' );
二,数据迁移
#数据库迁移:
从单机web02迁移到DB01独立的mysql
1,web02:压缩:
[root@web02 ~]# mysqldump -uroot -poldboy123 -A -B|gzip >/tmp/web02_db.sql.gz
mysqldump: [Warning] Using a password on the command line interface can be insecure.,
2,拷贝到异机DB01:
[root@web02 ~]# scp /tmp/web02_db.sql.gz 10.0.0.51:/tmp
3,把web02的数据库关闭
systemctl stop mysqld
systemctl disable mysqld
lsof -i :3306
4,配置web02的wp-config.php
[root@web02 /application/nginx/html/WordPress]# vim wp-config.php
define( 'DB_NAME', 'wordpress' );
/** MySQL database username */
define( 'DB_USER', 'wordpress' );
/** MySQL database password */
define( 'DB_PASSWORD', 'oldboy123' );
/** MySQL hostname */
define( 'DB_HOST', '172.16.1.51' ); #DB01的ip
5,在DB01解压web02传过来的数据库:
[root@db01 ~]# cd /tmp
[root@db01 /tmp]# gzip -d web02_db.sql.gz
[root@db01 /tmp]# mysql
grant all privileges on wordpress.* to wordpress@'172.16.1.%' identified by 'oldboy123';
flush privileges;
select user,authentication_string,host from mysql.user;