搭建WordPress博客程序库

搭建WordPress博客程序库

wordpress简介

wordpress是一套利用PHP语言和Mysql数据库开发的开源免费的Blog(博客,网站)程序,用户可以在支持PHP环境和Mysql数据库的服务器上建立Blog站点,他的功能非常强大,插件众多,易于扩充功能。目前wordpress已经成为主流的Blog搭建平台,很多发布平台都是根据WordPress二次开发,如果你也想像大牛一样拥有自己的Blog,可以购买网上的域名及空间,然后搭建LNMP环境,再部署WordPress程序后就可以轻松完成自己的梦想。

注意:建立博客程序需要建立在mysql数据库上,所有要先登录mysql数据库

具体操作步骤

###环境准备###
登录MySQL删除多余的库
mysql -uroot -psyz123
show databases;
drop database test;  #(测试用的test库,可以删掉,其他的库可以留下)

###创建WordPress专用库###
create database wordpress;

###授权###
grant all on wordpress.* wordpress@'localhost' identified by '123456';

###查看用户和权限###
select user,host from mysql.user;
show grants for wordpress@'localhost';

###刷新让其生效###
flush privileges;

 调整Nginx+PHP

###切换到nginx安装目录下###
cd /application/nginx/conf/extra/

###添加一个首页文件:index.php###
vim blog.conf

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

打开wordpress网址,下载安装包

###下载wordpress安装文件到tool/目录下###
cd /home/syz/tools/
wget https://cn.wordpress.org/wordpress-4.5.1-zh_CN.tar.gz
tar xf wordpress-4.5.1-zh_CN.tar.gz

###只拷贝wordpress下面的全部内容到blog/下###
cp -a wordpress/* /application/nginx/html/blog/

###修改权限(注意安全限制,动静态权限)###
chown -R www.www /application/nginx/html/blog/

###重启nginx###
/application/nginx/sbin/nginx -t
/application/nginx/sbin/nginx -s reload
然后hosts解析,web浏览器输入:blog.etiantian.org,出现wordpress安装页面即为正确(可以按照网页提示安装WordPress即可)

注意:

这一步授权的意义:
###修改权限(注意安全限制,动静态权限)###
chown -R www.www /application/nginx/html/blog/

实现WordPress博客程序URL静态化

简介:向博客上传内容,默认是动态网页,所以需要伪静态化网页

实现此功能时,首先要在WordPress后台依次点击设置-固定连接-自定义结构,然后输入以下代码,保存更改:/archives/%post_id%.html

###然后更改nginx的blog.conf文件###
cd /application/nginx/conf/
cd extra/

vim blog.conf

server {
      listen 80;
      server_name blog.etiantian.org;
      location / {
           root html/blog;
           index index.php index.html index.htm;

      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;
         }
      }

     location ~ .*\.(php|php5)?$ {
        root html/blog;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
      }
}

###检查并重启Nginx###
../../sbin/nginx -t
../../sbin/nginx -s reload

###查看是否实现伪静态###
web输入blog.etiantian.org,查看其域名后面,有无?等特殊字符显示,如果没有即为成功!

posted @ 2019-02-01 21:37  LEO00  阅读(329)  评论(0编辑  收藏  举报