LNMP环境搭建wordpress博客及伪静态
WordPress是使用PHP语言开发的博客平台,是一款开源的软件,用户可以在支持PHP和MySQL数据库的服务器上架设属于自己的网站。也可以把 WordPress当作一个内容管理系统(CMS)来使用。因为使用者众多,所以WordPress社区非常活跃,有丰富的插件模板资源。使用WordPress可以快速搭建独立的博客网站。
官网:https://cn.wordpress.org/中文文档:https://codex.wordpress.org/zh-cn:Main_Page
一、LNMP环境的搭建详情:https://www.cnblogs.com/su-root/p/11073215.html
二、搭建wordpress bolog博客程序准备:
mysql数据库配置准备:
登陆mysql数据库:
mysql –uroot –p123456
创建并授权一个专用的数据库wordpress用于存放blog数据:
create database wordpress;
show database like ‘wordpress’;
grant all on worpress.* to worpress@'localhost' identified by '123456';
注:当数据库和php服务不在同一台机器上,可执行如下命令授权
grant all on wordpress.* to wordpress@’192.168.0.%’ identified by ‘123456’;
刷新权限,使得创建的用户生效:
flush privileges;
查看用户对应的权限:
select user,host from mysql.user where user='wordpress';
博客程序下载:
[root@bqh- blog]# wget https://cn.wordpress.org/wordpress-4.2.2-zh_CN.tar.gz
[root@bqh- blog]# ls
wordpress-4.2.-zh_CN.tar.gz
[root@bqh- blog]# tar xf wordpress-4.2.-zh_CN.tar.gz
[root@bqh- blog]# ll
总用量
drwxr-xr-x nobody nfsnobody 5月 wordpress
-rw-r--r-- root root 6月 : wordpress-4.2.-zh_CN.tar.gz
[root@bqh- blog]# mv wordpress/* .
[root@bqh-118 blog]# ls
index.php wordpress-4.2.2-zh_CN.tar.gz wp-comments-post.php wp-includes wp-mail.php xmlrpc.php
license.txt wp-activate.php wp-config-sample.php wp-links-opml.php wp-settings.php
readme.html wp-admin wp-content wp-load.php wp-signup.php
wordpress wp-blog-header.php wp-cron.php wp-login.php wp-trackback.php
[root@bqh-118 blog]#rm –rf wordpress/ #删掉,避免带路径
nginx环境配置准备:
[root@bqh- conf]# vim nginx.conf
worker_processes ;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout ; server {
listen ;
server_name www.test.com;
root html/blog;
location / {
index index.php index.html index.htm;
}
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
include fastcgi.conf;
}
error_page /50x.html;
}
}
php环境配置准备:
[root@bqh- html]# chown -R root.root blog/
[root@bqh- html]# find ./blog/ -type f|xargs chmod
[root@bqh- html]# find ./blog/ -type d|xargs chmod
[root@bqh- html]# mkdir -p ./blog/wp-content/uploads
但是这样设置用户无法更改头像,上传图片,我们可以单独给他们设置权限。
[root@bqh- html]# chown -R nginx.nginx ./blog/wp-content/uploads #网站上传目录权限,没有则创建一个即可
修改所有php文件属主为root,避免网站php程序遭到篡改
[root@bqh- html]# find ./blog/ -type f -name "*.php"|xargs chown -R root.root
现在我们启动nginx服务、php服务、mysql服务:
[root@bqh- html]# /application/nginx/sbin/nginx
[root@bqh- html]# /application/php/sbin/php-fpm
[root@bqh- html]# /etc/init.d/mysqld start

打开浏览器:www.test.com



由于前期我们把权限搞了,现在需要复制出来,手动创建wp-config.php文件传上去即可。当然也可以在前面把安全降低777也行,后期再加固权限。


此时我们查询下数据库里面的信息:



ok,我们现在发一个博客试试:



我们查看一下上传图片路径,发现有多张图片,原因是博客优化图片来着(主页展示图片跟文章展示图片大小)

同时我们还发现网址后面带参数,说明是动态博客。
下面我们为wordpress博客设置伪静态规则:
1.打开博客后台登录进去----设置----固定连接----自定义结构,输入下面的代码保存即可:

自定义结构帮助:https://codex.wordpress.org/Using_Permalinks
2. nginx配置文件的server容器中添加下面的代码:(红色部分)
[root@bqh- conf]# vim nginx.conf
worker_processes ;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout ; server {
listen ;
server_name www.test.com;
root html/blog;
location / {
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)?$ {
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
include fastcgi.conf;
}
error_page /50x.html;
}
}
[root@bqh- conf]# /application/nginx/sbin/nginx -t
nginx: the configuration file /application/nginx-1.6./conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.6./conf/nginx.conf test is successful
[root@bqh- conf]# /application/nginx/sbin/nginx -s reload

我们进入mysql 可以查看到原始的地址加以对比:
[root@bqh- conf]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.5. MySQL Community Server (GPL) Copyright (c) , , Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use wordpress;
Database changed
mysql> show tables;
+-----------------------+
| Tables_in_wordpress |
+-----------------------+
| bh_commentmeta |
| bh_comments |
| bh_links |
| bh_options |
| bh_postmeta |
| bh_posts |
| bh_term_relationships |
| bh_term_taxonomy |
| bh_terms |
| bh_usermeta |
| bh_users |
+-----------------------+
11 rows in set (0.00 sec) mysql> select * from bh_posts\G;

php.ini 配置文件的深入解析详情见:https://www.jb51.net/article/38632.htm
LNMP环境搭建wordpress博客及伪静态的更多相关文章
- LNMP环境搭建Wordpress博客
目录 LNMP架构工作原理 yum源安装 网站源包安装 LNMP是Linux Nginx MySQL/MariaDB Php/perl/python 的简称,是近些年才逐渐发展起来的构架,发展非常迅 ...
- 基于LNMP架构搭建wordpress博客之安装架构说明
架构情况 架构情况:基于LNMP架构搭建wordpress系统 软件包版本说明: 系统要求 : CentOS-6.9-x86_64-bin-DVD1.iso PHP版本 : php-7.2.29 ...
- 搭建LNMP环境部署Wordpress博客
!!!首先要做的就是关闭系统的防火墙以及selinux: #systemctl stop firewalld #systemctl disable firewalld #sed -ri 's/^(SE ...
- Docker搭建wordpress博客环境(Centos7)
Docker搭建wordpress博客环境(Centos7) 升级系统 yum -y update 设置docker库 sudo yum install -y yum-utils sudo yum-c ...
- 搭建WordPress博客程序库
搭建WordPress博客程序库 wordpress简介 wordpress是一套利用PHP语言和Mysql数据库开发的开源免费的Blog(博客,网站)程序,用户可以在支持PHP环境和Mysql数据库 ...
- 烂泥:使用nginx利用虚拟主机搭建WordPress博客
本文由秀依林枫提供友情赞助,首发于烂泥行天下. 最近开始打算学习nginx web服务器,既然是学习还是以实用为目的的.我们在此以搭建WordPress博客为例. 搭建WordPress博客,我们需要 ...
- Centos 7使用docker部署LAMP搭建wordpress博客系统
0.简要概述 LAMP是目前比较流行的web框架,即Linux+Apache+Mysql+PHP的网站架构方案.docker是目前非常流行的虚拟化应用容器,可以为任何应用创建一个轻量级.可移植的容器. ...
- 搭建 WordPress 博客教程
搭建 WordPress 博客教程(超详细) 在 2018年7月29日 上张贴 由 suncent一条评论 本文转自:静候那一米阳光 链接:https://www.jianshu.com/p/5675 ...
- 免费搭建wordpress博客有感
之前一直有搭建个wordpress博客的想法,但一直没有实施.最近离职之后,空闲时间多了起来,就开始折腾wordpress博客起来. wordpress博客可玩性很高,但刚开始只想练练手,就没有想买域 ...
随机推荐
- Spring cloud微服务安全实战-5-8实现基于session的SSO(认证服务器的session有效期)
认证服务器 session的有效期. 也就是认证服务器上的session的有效期 生成环境下,认证服务器一定是一个集群.集群.那么session一定是要在所有的服务器之间进行共享的.最简单的方式是用S ...
- Java程序员金三银四精心准备的面试题及答案(基础篇)
1.面向对象的特征有哪些方面? [基础] 答:面向对象的特征主要有以下几个方面: 1)抽象:抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面.抽象并不打算了解全部问 ...
- 【JS新手教程】replace替换一个字符串中所有的某单词
JS中的replace方法可以替换一个字符串中的单词.语句的格式是: 需要改的字符串.replace(字符串或正则表达式,替换成的字符串) 如果第一个参数用字符串,默认是找到该字符串中的第一个匹配的字 ...
- Office 2010 经验总结
1. 如何设置蓝底白字? 答:点击菜单项上的"页面布局"→"页面颜色",就可以选择喜欢的页面颜色,字体颜色也会跟着发生改变. 补充:如果不喜欢相应的页面颜色中系 ...
- 推荐linux运维必备的几本书
首先,<鸟哥的linux私房菜> 鸟哥 其次,<linux就该这么学> 刘瑞版 然后,<CentOS linux系统运维> 张祥琳版 最后,<CentOS运维 ...
- UN Report: Last 10 Years Likely the Hottest Decade on Record——VOA慢速英语
听力地址:UN Report: Last 10 Years Likely the Hottest Decade on Record 中英对照:联合国报告称过去十年可能是有记录以来最热的十年 Words ...
- 如何将生产环境的服务Docker镜像拉取到本地进行调试
背景 很多时候我们在将开发环境的代码推送到GitLab上面以后,我们在测试的时候发现了问题后无法通过现有的日志输出级别来定位问题,比如我们需要看EFCore生成的SQL语句,在生产环境我们是不可能输出 ...
- 以php中的自增自自减运算符操作(整型,浮点型,字符串型,布尔型,空类型)数据
// 环境 // // php版本 // PHP 7.0.33-0+deb9u1 (cli) (built: Dec 7 2018 11:36:49) ( NTS ) // Copyright (c) ...
- python 之 数据库(修改表、复制表、删除表、单表查询)
10.8 修改表.复制表.删除表 10.81 修改表 alter table . 修改表名 alter table 表名 rename 新表名; . 增加字段 alter table 表名 add 字 ...
- python数据库基础
1.数据类型:(使用原则:够用就行,尽量使用范围小的) 整数:int,bit 小数:decimal 字符串:varchar(可变长度),char(固定长度字符串) 日期时间:date,time,dat ...