lnmp博客伪静态实践完成

简介:

lnmp博客伪静态实践完成

打开wordpress后台管理界面:设置-固定链接-自定义结构中输入:/archives/%post_id%.html

保存。

然后打开web01,vi /application/nginx/conf/extra/blog.conf输入如下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@web01 ~] # cat /application/nginx/conf/extra/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;
         }
     }


(提示:把上图中的

1
<span style= "background-color:rgb(255,255,0);" > if  (-f $request_filename /index .html) {<br>        rewrite (.*) $1 /index .html  break ;<br>  }<br> if  (-f $request_filename /index .php) {<br>        rewrite (.*) $1 /index .php;<br>  }<br> if  (!-f $request_filename) {<br>        rewrite (.*)  /index .php;<br>  }<br>< /span >

用下面的

1
<span style= "background-color:rgb(255,255,0);" >try files $uri $uri/  /index .php?q=$uri&$args;<br>< /span >

替换,也可以达到预期效果。)


检查nginx语法并平滑重启

1
2
3
4
[root@web01 ~] # /application/nginx/sbin/nginx -t
nginx: the configuration  file  /application/nginx-1 .6.3 //conf/nginx .conf syntax is ok
nginx: configuration  file  /application/nginx-1 .6.3 //conf/nginx .conf  test  is successful
[root@web01 ~] # /application/nginx/sbin/nginx -s reload

再次打开wordpress blog里面的文章,发现网址已经变成了伪静态了。

wKiom1miwCGS86CdAAJutwP_GBY197.jpg

本文转自sandshell博客51CTO博客,原文链接http://blog.51cto.com/sandshell/1959761如需转载请自行联系原作者


sandshell

相关文章
|
应用服务中间件 Apache nginx
LNMP环境中WordPress程序伪静态解决方案
LNMP环境是目前我们国内站长使用的Linux VPS配置环境中使用较多的。作为新手我们很可能会看到老左类似的"LNMP安装教程"然后依葫芦画瓢的去安装VPS。我们是否有发现环境中我们较为常用的wordpress伪静态不生效,内页出现404错误页面。
2090 0
|
关系型数据库 应用服务中间件 PHP
|
应用服务中间件 PHP nginx
CentOS 下用的是lnmp 的包配置Nginx 下的CI伪静态(搞爽了)
server { listen 80; server_name cy.com; index index.
1040 0
|
7月前
|
关系型数据库 MySQL 应用服务中间件
手动部署LNMP环境(Alibaba Cloud Linux 2)
本场景带您体验如何在Alibaba Cloud Linux 2.1903 LTS 64位操作系统的云服务器上搭建LNMP环境。
202 0
|
4月前
|
关系型数据库 应用服务中间件 nginx
基于Docker的LNMP环境微服务搭建
基于Docker的LNMP环境微服务搭建
基于Docker的LNMP环境微服务搭建
|
7月前
|
应用服务中间件 PHP nginx
基于Anolis OS 3快速搭建LNMP环境制作KodBox
本教程介绍如何搭建LNMP环境,其中本实验的LNMP分别代表Anolis OS 3、Nginx、Mariadb和PHP。
135 0
|
7月前
|
关系型数据库 MySQL 应用服务中间件
快速搭建LNMP环境
Nginx是一款小巧而高效的Web服务器软件,可帮您在Linux系统下快速方便地搭建出LNMP Web服务环境。本教程介绍如何搭建LNMP环境,其中LNMP分别代表Linux、Nginx、MySQL和PHP。
287 2
|
3月前
|
API PHP 数据库
Docker六脉神剑(四) 使用Docker-Compose进行服务编排搭建lnmp环境
Docker六脉神剑(四) 使用Docker-Compose进行服务编排搭建lnmp环境
33 0