搭建WordPress博客程序库

搭建WordPress博客程序库

wordpress简介

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

注意:创建博客程序须要创建在mysql数据库上,全部要先登陆mysql数据库html

具体操做步骤

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

###建立WordPress专用库###
create database wordpress;nginx

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

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

###刷新让其生效###
flush privileges;数据库

 调整Nginx+PHP

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

###添加一个首页文件: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,查看其域名后面,有无?等特殊字符显示,若是没有即为成功!

相关文章
相关标签/搜索