WordPress搭建個人部落格

來源:互聯網
上載者:User

本文主要和大家分享WordPress搭建個人部落格,主要以圖文和代碼的形式和大家分享,希望能協助到大家。

1 LNMP組合

1.1 驗證Nginx到php的連通性

在前幾篇博文中所有環境都已經配置好了,下面測試Nginx和php之間的連通

LNMP之Nginx服務搭建及三種類型虛擬機器主機
LNMP之二進位安裝mysql-5.5.54
LNMP之源碼編譯安裝php-5.5.32

# 修改/application/nginx/conf/extra/blog.conf[root@web01 extra]# cat blog.conf    server {        listen       80;        server_name  blog.rsq.com;        location / {            root   html/blog;            index  index.html index.htm;        }        location ~ .*\.(php|php5)?$ {            root html/blog;        fastcgi_pass 127.0.0.1:9000;        fastcgi_index index.php;        include fastcgi.conf;        }    }# 重啟nginx服務[root@web01 extra]# ../../sbin/nginx -tnginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is oknginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful[root@web01 extra]# ../../sbin/nginx -s reload# 在/application/nginx/html/blog/目錄中寫一個phpinfo檔案,測試連通性[root@web01 extra]# cd /application/nginx/html/blog/[root@web01 blog]# echo "<?php phpinfo(); ?>" >test_info.php[root@web01 blog]# cat test_info.php<?php phpinfo(); ?>

# windows瀏覽器中做訪問測試,若出現以下頁面則測試成功

1.2 驗證php到mysql的連通性

# 寫一個簡單的資料庫連接指令碼[root@web01 blog]# cat test_mysql.php<?php    $link_id=mysql_connect('localhost','root','oldboy123') or mysql_error();    if($link_id){        echo "Mysql successful by RSQ !";    }else{        echo mysql_error();    }?>

# 瀏覽器端測試

2 LNMP之wordpress個人部落格搭建

2.1 建立wordpress資料庫

# 先登入mysql,建立WordPress所需要的資料庫[root@web01 ~]# mysql -uroot -poldboy123mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema || test               |+--------------------+4 rows in set (0.01 sec)mysql> drop database test;          # 刪除多餘的test資料庫Query OK, 0 rows affected (0.02 sec)mysql> show databases;          #顯示資料庫+--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema |+--------------------+3 rows in set (0.00 sec)mysql> create database wordpress;           # 建立wordpress使用者Query OK, 1 row affected (0.00 sec)mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema || wordpress          |+--------------------+4 rows in set (0.00 sec)mysql> select user();+----------------+| user()         |+----------------+| root@localhost |+----------------+1 row in set (0.00 sec)mysql> select user,host from mysql.user;        #查看當前資料庫使用者+------+-----------+| user | host      |+------+-----------+| root | 127.0.0.1 || root | ::1       ||      | localhost || root | localhost |+------+-----------+4 rows in set (0.00 sec)# 為wordpress資料庫建立專門管理的wordpress使用者並授予所有許可權mysql> grant all on wordpress.* to wordpress@'localhost' identified by '123456';        Query OK, 0 rows affected (0.00 sec)mysql> select user,host from mysql.user;    # 查看wordpress資料庫使用者是否建立+-----------+-----------+| user      | host      |+-----------+-----------+| root      | 127.0.0.1 || root      | ::1       ||           | localhost || root      | localhost || wordpress | localhost |+-----------+-----------+5 rows in set (0.00 sec)mysql> show grants for wordpress@'localhost';   # 查看指定使用者所具有的許可權mysql> flush privileges;        # 重新整理一下,使使用者權限生效Query OK, 0 rows affected (0.00 sec)

2.2 修改blog.conf設定檔

# blog.conf設定檔中index新增index.html[root@web01 extra]# cat blog.conf     server {        listen       80;        server_name  blog.rsq.com;        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;        }    }[root@web01 tools]# /application/nginx/sbin/nginx -t nginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is oknginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful[root@web01 tools]# /application/nginx/sbin/nginx -s reload

2.3 下載wordpress軟體包

# 先去官網查看所支援外掛程式的版本

# 去官網下載最新的wordpress軟體包[root@web01 extra]# cd /home/oldboy/tools/[root@web01 tools]# wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz# 解壓縮[root@web01 tools]# tar -xf wordpress-4.9.4-zh_CN.tar.gz# 拷貝wordpress目錄下的所有內容到/application/nginx/html/blog/目錄下[root@web01 tools]# cp -a wordpress/* /application/nginx/html/blog/[root@web01 tools]# ls /application/nginx/html/blog/index.php        wp-blog-header.php    wp-includes        wp-settings.phplicense.txt      wp-comments-post.php  wp-links-opml.php  wp-signup.phpreadme.html      wp-config-sample.php  wp-load.php        wp-trackback.phpwp-activate.php  wp-content            wp-login.php       xmlrpc.phpwp-admin         wp-cron.php           wp-mail.php# 授予許可權,先暫時授予所有檔案,以後再調整許可權[root@web01 tools]# chown -R www.www /application/nginx/html/blog/

2.4 網頁安裝wordpress

# 用戶端 hosts檔案要做解析

———————————————END!

目錄



  • 1 LNMP組合

    • 1.1 驗證Nginx到php的連通性

    • 1.2 驗證php到mysql的連通性

  • 2 LNMP之wordpress個人部落格搭建

    • 2.1 建立wordpress資料庫

    • 2.2 修改blog.conf設定檔

    • 2.3 下載wordpress軟體包

    • 2.4 網頁安裝wordpress

1 LNMP組合

1.1 驗證Nginx到php的連通性

在前幾篇博文中所有環境都已經配置好了,下面測試Nginx和php之間的連通

LNMP之Nginx服務搭建及三種類型虛擬機器主機
LNMP之二進位安裝mysql-5.5.54
LNMP之源碼編譯安裝php-5.5.32

# 修改/application/nginx/conf/extra/blog.conf[root@web01 extra]# cat blog.conf    server {        listen       80;        server_name  blog.rsq.com;        location / {            root   html/blog;            index  index.html index.htm;        }        location ~ .*\.(php|php5)?$ {            root html/blog;        fastcgi_pass 127.0.0.1:9000;        fastcgi_index index.php;        include fastcgi.conf;        }    }# 重啟nginx服務[root@web01 extra]# ../../sbin/nginx -tnginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is oknginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful[root@web01 extra]# ../../sbin/nginx -s reload# 在/application/nginx/html/blog/目錄中寫一個phpinfo檔案,測試連通性[root@web01 extra]# cd /application/nginx/html/blog/[root@web01 blog]# echo "<?php phpinfo(); ?>" >test_info.php[root@web01 blog]# cat test_info.php<?php phpinfo(); ?>

# windows瀏覽器中做訪問測試,若出現以下頁面則測試成功

1.2 驗證php到mysql的連通性

# 寫一個簡單的資料庫連接指令碼[root@web01 blog]# cat test_mysql.php<?php    $link_id=mysql_connect('localhost','root','oldboy123') or mysql_error();    if($link_id){        echo "Mysql successful by RSQ !";    }else{        echo mysql_error();    }?>

# 瀏覽器端測試

2 LNMP之wordpress個人部落格搭建

2.1 建立wordpress資料庫

# 先登入mysql,建立WordPress所需要的資料庫[root@web01 ~]# mysql -uroot -poldboy123mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema || test               |+--------------------+4 rows in set (0.01 sec)mysql> drop database test;          # 刪除多餘的test資料庫Query OK, 0 rows affected (0.02 sec)mysql> show databases;          #顯示資料庫+--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema |+--------------------+3 rows in set (0.00 sec)mysql> create database wordpress;           # 建立wordpress使用者Query OK, 1 row affected (0.00 sec)mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema || wordpress          |+--------------------+4 rows in set (0.00 sec)mysql> select user();+----------------+| user()         |+----------------+| root@localhost |+----------------+1 row in set (0.00 sec)mysql> select user,host from mysql.user;        #查看當前資料庫使用者+------+-----------+| user | host      |+------+-----------+| root | 127.0.0.1 || root | ::1       ||      | localhost || root | localhost |+------+-----------+4 rows in set (0.00 sec)# 為wordpress資料庫建立專門管理的wordpress使用者並授予所有許可權mysql> grant all on wordpress.* to wordpress@'localhost' identified by '123456';        Query OK, 0 rows affected (0.00 sec)mysql> select user,host from mysql.user;    # 查看wordpress資料庫使用者是否建立+-----------+-----------+| user      | host      |+-----------+-----------+| root      | 127.0.0.1 || root      | ::1       ||           | localhost || root      | localhost || wordpress | localhost |+-----------+-----------+5 rows in set (0.00 sec)mysql> show grants for wordpress@'localhost';   # 查看指定使用者所具有的許可權mysql> flush privileges;        # 重新整理一下,使使用者權限生效Query OK, 0 rows affected (0.00 sec)

2.2 修改blog.conf設定檔

# blog.conf設定檔中index新增index.html[root@web01 extra]# cat blog.conf     server {        listen       80;        server_name  blog.rsq.com;        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;        }    }[root@web01 tools]# /application/nginx/sbin/nginx -t nginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is oknginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful[root@web01 tools]# /application/nginx/sbin/nginx -s reload

2.3 下載wordpress軟體包

# 先去官網查看所支援外掛程式的版本

# 去官網下載最新的wordpress軟體包[root@web01 extra]# cd /home/oldboy/tools/[root@web01 tools]# wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz# 解壓縮[root@web01 tools]# tar -xf wordpress-4.9.4-zh_CN.tar.gz# 拷貝wordpress目錄下的所有內容到/application/nginx/html/blog/目錄下[root@web01 tools]# cp -a wordpress/* /application/nginx/html/blog/[root@web01 tools]# ls /application/nginx/html/blog/index.php        wp-blog-header.php    wp-includes        wp-settings.phplicense.txt      wp-comments-post.php  wp-links-opml.php  wp-signup.phpreadme.html      wp-config-sample.php  wp-load.php        wp-trackback.phpwp-activate.php  wp-content            wp-login.php       xmlrpc.phpwp-admin         wp-cron.php           wp-mail.php# 授予許可權,先暫時授予所有檔案,以後再調整許可權[root@web01 tools]# chown -R www.www /application/nginx/html/blog/

2.4 網頁安裝wordpress

# 用戶端 hosts檔案要做解析

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.