1    配置相關資料庫
登入 mysql

1

[root@web01 blog]# mysql -uroot -p123456

顯示所有的資料庫:

1

show databases;

顯示如下:

1
2
3
4
5
6
7
8
9
10

mysql> show databases;
+——————–+
| Database           |
+——————–+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+——————–+
4 rows in set (0.05 sec)

用命令 drop database test; 把沒有用的 test 資料庫刪除

1
2

mysql> drop database test;
Query OK, 0 rows affected (0.06 sec)

繼續 show databases; 檢視資料庫數量

1
2
3
4
5
6
7
8
9

mysql> show databases;    
+——————–+
| Database           |
+——————–+
| information_schema |
| mysql              |
| performance_schema |
+——————–+
3 rows in set (0.00 sec)

用命令 create database wordpress; 建立一個專用的資料庫 wordpress,用於存放 blog 資料。

1
2

mysql> create database wordpress;
Query OK, 1 row affected (0.00 sec)

用命令 show databases; 再檢視資料庫數量

1
2
3
4
5
6
7
8
9
10

mysql> show databases;
+——————–+
| Database           |
+——————–+
| information_schema |
| mysql              |
| performance_schema |
| wordpress          |
+——————–+
4 rows in set (0.00 sec)

檢視誰是資料庫管理員 select user();

1
2
3
4
5
6
7

mysql> select user();
+—————-+
| user()         |
+—————-+
| root@localhost |
+—————-+
1 row in set (0.00 sec)

檢視系統誰是系統管理員 system whoami

1
2

mysql> system whoami
root

檢視 mysql 資料庫的所有使用者 select user,host from mysql.user;

1
2
3
4
5
6
7
8
9
10
11
12

mysql> select user,host from mysql.user;
+——+———–+
| user | host      |
+——+———–+
| root | 127.0.0.1 |
| root | ::1       |
|      | localhost |
| root | localhost |
|      | web01     |
| root | web01     |
+——+———–+
6 rows in set (0.00 sec)

建立 wordpress 使用者針對於 wordpress 裡面的所有表管理
grant all on wordpress.* to wordpress@’localhost’ identified by ‘123456’;

1
2

mysql> grant all on wordpress.* to wordpress@’localhost’ identified by ‘123456’;
Query OK, 0 rows affected (0.00 sec)

查詢下剛剛增加的使用者是否生效 select user,host from mysql.user;

1
2
3
4
5
6
7
8
9
10
11
12
13

mysql> select user,host from mysql.user;                                                       
+———–+———–+
| user      | host      |
+———–+———–+
| root      | 127.0.0.1 |
| root      | ::1       |
|           | localhost |
| root      | localhost |
| wordpress | localhost |
|           | web01     |
| root      | web01     |
+———–+———–+
7 rows in set (0.00 sec)

檢視使用者對應的許可權 show grants for wordpress@’localhost’;

1
2
3
4
5
6
7
8

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)

重新整理資料庫,讓許可權生效 flush privileges;

1
2

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

調整 nginx+php

1
2

[root@web01 blog]# cd /application/nginx/conf/extra/
[root@web01 extra]# vim blog.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14

    server {
        listen       80;
        server_name  blog.etiantian.org;
        location / {
            root   html/blog;
            index  index.php index.html index.htm;
        }
        location ~ .*.(php|php5)?$ {
            root   html/blog;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
        }
    }

2    下載部落格網站
輸入地址:https://cn.wordpress.org/ 複製 tar 版本路徑  https://cn.wordpress.org/wordpress-4.8.1-zh_CN.tar.gz

然後再下載部落格網站程式

1
2

[root@web01 extra]# cd /home/oldboy/tools
[root@web01 tools]# wget https://cn.wordpress.org/wordpress-4.8.1-zh_CN.tar.gz

解壓 wordpress

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

[root@web01 tools]# ll
total 212988
drwxr-xr-x 22 root root      4096 Aug 24 21:05 libiconv-1.14
-rw-r–r–  1 root root   4984397 Aug  8  2011 libiconv-1.14.tar.gz
-rw-r–r–  1 root root 185870973 Aug 23 19:57 mysql-5.5.49-linux2.6-x86_64.tar.gz
drwxr-xr-x  9 1001 1001      4096 Aug 19 16:11 nginx-1.6.3
-rw-r–r–  1 root root    805253 Apr  8  2015 nginx-1.6.3.tar.gz
drwxr-xr-x 17 1001 1001      4096 Aug 24 23:45 php-5.5.32
-rw-r–r–  1 root root  17773092 Aug 24 21:24 php-5.5.32.tar.gz
-rw-r–r–  1 root root   8641990 Aug  4 15:54 wordpress-4.8.1-zh_CN.tar.gz
[root@web01 tools]# tar xf wordpress-4.8.1-zh_CN.tar.gz 
[root@web01 tools]# ls wordpress
index.php        wp-admin              wp-content         wp-load.php      wp-signup.php
license.txt      wp-blog-header.php    wp-cron.php        wp-login.php     wp-trackback.php
readme.html      wp-comments-post.php  wp-includes        wp-mail.php      xmlrpc.php
wp-activate.php  wp-config-sample.php  wp-links-opml.php  wp-settings.php

複製到部落格網站下面

1

[root@web01 tools]# cp -a wordpress/* /application/nginx/html/blog/

1
2
3
4
5
6

[root@web01 tools]# ls /application/nginx/html/blog/
index.html     test_mysql.php        wp-config-sample.php  wp-load.php      wp-trackback.php
index.php      wp-activate.php       wp-content            wp-login.php     xmlrpc.php
license.txt    wp-admin              wp-cron.php           wp-mail.php
readme.html    wp-blog-header.php    wp-includes           wp-settings.php
test_info.php  wp-comments-post.php  wp-links-opml.php     wp-signup.php

設定許可權

1

[root@web01 tools]# chown -R www.www /application/nginx/html/blog/

檢視許可權

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

[root@web01 tools]# ll /application/nginx/html/blog/
total 200
-rw-r–r–  1 www www     5 Aug 19 23:17 index.html
-rw-r–r–  1 www www   418 Sep 25  2013 index.php
-rw-r–r–  1 www www 19935 Jan  3  2017 license.txt
-rw-r–r–  1 www www  6956 Aug  4 15:54 readme.html
-rw-r–r–  1 www www    20 Aug 25 00:35 test_info.php
-rw-r–r–  1 www www   167 Aug 27 00:11 test_mysql.php
-rw-r–r–  1 www www  5447 Sep 28  2016 wp-activate.php
drwxr-xr-x  9 www www  4096 Aug  4 15:54 wp-admin
-rw-r–r–  1 www www   364 Dec 19  2015 wp-blog-header.php
-rw-r–r–  1 www www  1627 Aug 29  2016 wp-comments-post.php
-rw-r–r–  1 www www  2930 Aug  4 15:54 wp-config-sample.php
drwxr-xr-x  5 www www  4096 Aug  4 15:54 wp-content
-rw-r–r–  1 www www  3286 May 25  2015 wp-cron.php
drwxr-xr-x 18 www www 12288 Aug  4 15:54 wp-includes
-rw-r–r–  1 www www  2422 Nov 21  2016 wp-links-opml.php
-rw-r–r–  1 www www  3301 Oct 25  2016 wp-load.php
-rw-r–r–  1 www www 34327 May 13 01:12 wp-login.php
-rw-r–r–  1 www www  8048 Jan 11  2017 wp-mail.php
-rw-r–r–  1 www www 16200 Apr  7 02:01 wp-settings.php
-rw-r–r–  1 www www 29924 Jan 24  2017 wp-signup.php
-rw-r–r–  1 www www  4513 Oct 15  2016 wp-trackback.php
-rw-r–r–  1 www www  3065 Sep  1  2016 xmlrpc.php

檢查語法,重啟 nginx

1
2
3
4

[root@web01 tools]# /application/nginx/sbin/nginx -t
nginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful
[root@web01 tools]# /application/nginx/sbin/nginx -s reload

瀏覽器中輸入 blog.etiantian.org 回車,出現如下介面說明配置對了

配置部落格網站:點選上圖 “現在就開始”,填寫如下資訊,點選提交