给 nginx 添加 Markdown 解析模块
来源:靑龍一笑的博客 作者:靑龍一笑 发布时间:2018-01-11 12:46:21 点击量:6097 评论:0
Markdown 是一种标记语言,通过简单的标记语法,可以使普通文本内容具有一定的格式。因为 Markdown 的语法简洁明了、学习容易,而且功能比纯文本更强。因此,很多人用它来写博客。
nginx 有一个模块 ngx-markdown-module-mdfilter,可以将网页中的 markdown 语法自动解析为 html。在添加这个模块之前,需要先安装 discount,因为 markdown 需要这个解析器。
[root@RicenOS softwares]# tar xvf discount-2.2.2.tar.bz2
[root@RicenOS softwares]# cd discount-2.2.2/
[root@RicenOS discount-2.2.2]# ./configure.sh
[root@RicenOS discount-2.2.2]# make
[root@RicenOS discount-2.2.2]# make install
[root@RicenOS discount-2.2.2]# cd ..
[root@RicenOS softwares]# cd discount-2.2.2/
[root@RicenOS discount-2.2.2]# ./configure.sh
[root@RicenOS discount-2.2.2]# make
[root@RicenOS discount-2.2.2]# make install
[root@RicenOS discount-2.2.2]# cd ..
解压 ngx-markdown-module-mdfilter-0.1.tar.gz,并移到 nginx 的安装目录下:
[root@RicenOS softwares]# tar xvf ngx-markdown-module-mdfilter-0.1.tar.gz
[root@RicenOS softwares]# mv ngx-markdown-module-mdfilter-0.1 nginx-1.12.2
[root@RicenOS softwares]# mv ngx-markdown-module-mdfilter-0.1 nginx-1.12.2
在配置 nginx 的时候,添加以下一行代码:
--add-module=ngx-markdown-module-mdfilter-0.1/ngx-md-filter-module/
至于其它的配置项,可以参考我的另外一篇文章:《在 Linux 系统下安装和配置 Nginx》。
安装完 nginx 后,在 nginx 的配置文件里添加以下代码:
location / {
root html;
index index.md;
}
location ~ /*.md {
mdfilter on;
mdfilter_utf8 on;
}
版权所有 © 2005-2023 靑龍一笑的博客 Powered by C.S.Ricen
Copyright © 2005-2023 by www.ricensoftwares.com.cn All Rights Reserved.
Copyright © 2005-2023 by www.ricensoftwares.com.cn All Rights Reserved.