在LNMP環境中部署一個blog服務程序

1、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
2、安裝blog博客程序
      打開瀏覽器輸入blog.etiantain.org(提早作好host或者DNS解析)安裝WordPress

php

相關文章
相關標籤/搜索