第二章、web01搭建博客
第一步、web01服务器环境配置准备
确认环境
netstat -lntup|egrep "80|3306|9000"
下载上传开源BLOG
cd /server/tools/
上传解压
rz
unzip wordpress-5.1.1.zip
把目录下所有移动到blog站点目录
mv wordpress/* /application/nginx/html/blog/
站点目录授权
chown -R nginx.nginx /application/nginx/html/blog/
查看站点目录属性
ls -ld /application/nginx/html/blog/
将博客中动态网页转化成伪静态网页
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
image
第二步、打开blog网页安装
第三章、数据库迁移:从单机LNMP迁移到DB01独立的mysql
第一步、db01服务器搭建Mysql数据库
步骤(一键脚本)
useradd mysql -s /sbin/nologin -M
id mysql
cd /server/tools/
tar xf mysql-5.7.26-linux- glibc2.12-x86_64.tar.gz
mkdir -p /application
mv mysql-5.7.26-linux-glibc2.12-x86_64
/application/mysql-5.7.26
ln -s /application/mysql-5.7.26/ /application/mysql
rpm -e --nodeps mariadb-libs
cat >/etc/my.cnf<<EOF
[mysqld]
basedir = /application/mysql/
datadir = /application/mysql/data
socket = /tmp/mysql.sock
server_id = 1
port = 3306
log_error = /application/mysql/data/oldboy_mysql.err
[mysql]
socket = /tmp/mysql.sock
prompt = oldboy [\\d]>
EOF
rpm -qa mariadb-libs
yum install libaio-devel -y
mkdir -p /application/mysql/data
chown -R mysql.mysql/application/mysql/
/application/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/application/mysql/ --datadir=/application/mysql/data
cat >/etc/systemd/system/mysqld.service<<EOF
[Unit]
Description=MySQL Server by oldboy
Documentation=man:mysqld(8)
Documentation=http://dev.mysq
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/application/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
EOF
systemctl start mysqld
systemctl enable mysqld
netstat -lntup|grep mysql
echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile
. /etc/profile
mysql
截图
image
image
第二步、web01服务器停止Mysql服务
备份:
mysqldump -uroot -poldboy123 -A -B|gzip >/tmp/web01_db.sql.gz
拷贝到db01:
scp /tmp/web01_db.sql.gz 10.0.0.51:/tmp
停止mysql服务
systemctl stop mysqld
systemctl disable mysqld
lsof -i :3306
cd /application/nginx/html/blog/
vim wp-config.php (修改主机名和IP地址)
image
第三步、db01服务器Mysql数据库配置
检查
lsof -i :3306
查看/tmp下文件
cd /tmp
解压文件
gzip -d web01_db.sql.gz
把文件里内容输送到mysql数据库
mysql </tmp/web01_db.sql
查看文件里内容
less web01_db.sql
mysql数据库配置
show databases;
grant all privileges on wordpress.* to wordpress@'172.16.1.%' identified by 'oldboy123';
flush privileges;
select user,authentication_string,host from mysql.user
image
image
网友评论