一、MySQL数据库配置准备
1.MySQL数据库配置准备
1)登录MySQL数据库
mysql -uroot -p
2)创建一个专用的数据库WordPress,用于存放blog数据
create database wordpress;
show databases like 'wordpress';#查看数据库
3)创建一个专用的WordPress blog管理用户
grant all on wordpress.* to wordpress@'localhost' identified by '123456';#创建一个专用的管理用户
flush privileges;#刷新权限使新建用户生效
show grants for wordpress@'localhost';#查看用户对用的权限
select user,host from mysql.user;#查看数据库中创建的wordpress用户
创建成功情况如下:
mysql> show databases like 'wordpress';
+----------------------+
| Database (wordpress) |
+----------------------+
| wordpress |
+----------------------+
1 row in set (0.00 sec)
mysql> grant all on wordpress.* to wordpress@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> show grants for wordpress@'localhost';
+------------------------------------------------------------------------------------------------------------------+
| Grants for wordpress@localhost |
+------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'wordpress'@'localhost' IDENTIFIED BY PASSWORD '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' |
| GRANT ALL PRIVILEGES ON `wordpress`.* TO 'wordpress'@'localhost' |
+------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> select user,host from mysql.user;
+-----------+-------------------+
| user | host |
+-----------+-------------------+
| root | 127.0.0.1 |
| root | ::1 |
| | instance-yf0xzby9 |
| root | instance-yf0xzby9 |
| | localhost |
| root | localhost |
| wordpress | localhost |#只允许本机通过wordpress用户访问数据库
+-----------+-------------------+
2.Nginx及PHP环境配置准备
1)选择前文配置好的支持LNMP的blog域名对应的虚拟主机
[root@instance-yf0xzby9 ~]# cd /application/nginx/conf/extra/
[root@instance-yf0xzby9 extra]# vi blog.conf
[root@instance-yf0xzby9 extra]# cat blog.conf
server {
listen 80;
server_name blog.etiantian.org;
location / {
root html/blog;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ .*.(php|php)?$ {
root html/blog;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
2)获取WordPress博客程序,并放置到blog域名对应虚拟主机的站点目录下,即html/blog
cd ../../html/blog
ls -sh wordpress-4.9.8.tar.gz
[root@instance-yf0xzby9 blog]# ls -sh wordpress-4.9.8.tar.gz
8.4M wordpress-4.9.8.tar.gz
[root@instance-yf0xzby9 blog]# pwd
/application/nginx/html/blog
[root@instance-yf0xzby9 blog]# tar xf wordpress-4.9.8.tar.gz
[root@instance-yf0xzby9 blog]# ls
index.html test_info.php wordpress wordpress-4.9.8.tar.gz
rm -f index.html test_mysql.php
mv wordpress/* . #将内容转移带blog根目录
/bin/mv wordpress-4.9.8.tar.gz /home/hty/tools/
ls -l
chown -R nginx.nginx ../blog/ #授权nginx及php服务访问blog站点目录
ls -l
二、安装blog博客程序
打开浏览器输入blog.etiantain.org(提前做好host或者DNS解析)安装WordPress