栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Windows下编译带fancyindex的nginx

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Windows下编译带fancyindex的nginx

Windows下编译带fancyindex的nginx
    • 一、准备
    • 二、下载nginx源代码
    • 三、添加依赖
    • 四、生成Makefile
    • 五、处理一些小问题
    • 六、编译
    • 七、执行前准备

系统环境:vs2019 buildtools
发布时间:2022.4,注意时效性

一、准备

由于要编译64位nginx,以下所有软件均使用64位

  1. git for windows (用msys2也行)
  2. strawberryperl 下载链接
  3. nasm 下载链接,解压后把所有可执行文件放在一个目录里,把这个目录加入PATH
  4. sed 下载链接,安装后把安装目录加入PATH
  5. 下载依赖库:pcre,zlib,openssl, ngx-fancyindex,注意:千万不要下载pcre2!
二、下载nginx源代码

看网上有人先下载安装Mercurial再下载源代码,但完全可以直接下载,进入链接,点击最上边的那个release,然后点击最左边的zip,我下的是stable-1.20.zip

三、添加依赖

在nginx源代码分别创建 objslib 文件夹,并且将下载好的ngx-fancyindex、openssl、pcre、zlib分别解压在lib文件夹下面

结果如下图:

四、生成Makefile

使用git bash,进入nginx根文件夹,执行
auto/configure --with-cc=cl --builddir=objs --prefix= --conf-path=conf/nginx.conf --pid-path=logs/nginx.pid --http-log-path=logs/access.log --error-log-path=logs/error.log --sbin-path=nginx.exe --http-client-body-temp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --http-scgi-temp-path=temp/scgi_temp --http-uwsgi-temp-path=temp/uwsgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs/lib/pcre-8.45 --with-zlib=objs/lib/zlib-1.2.11 --with-openssl=objs/lib/openssl-1.1.1n --with-select_module --with-http_ssl_module --add-module=objs/lib/ngx-fancyindex-0.5.2
如果有依赖库版本不一样的时候,注意更改


五、处理一些小问题

修改 nginxautolibopensslmakefile.msvc 文件,将9行VC-WIN32改为VC-WIN64A,将15行msdo_ms 改为 msdo_nasm
修改 autoccmsvc 文件,将83行-W4改为-W3,并将117和119行注释掉

六、编译

打开x64提示符,进入nginx根文件夹,执行nmake -f Makefile

等待一段时间后即可编译成功

七、执行前准备

将根目录中的conf、contrib、docs、misc文件夹复制到新文件夹,将objs/nginx.exe复制到该文件夹根目录下,新建temp、html文件夹
如图:

开启目录索引:编辑 conf/nginx.conf

location / {
    autoindex               on;
    autoindex_exact_size    off;
    autoindex_localtime     on;
    charset                 utf-8; # 如果中文有乱码,可配置为:gbk,utf-8
     
    fancyindex              on; # 启用插件
    fancyindex_localtime    on; # 使用本地时间
    fancyindex_exact_size   off; # 是否使用精确的大小,on显示字节,off显示如 M 这种
 
    fancyindex_footer       "/fancy-theme/footer.html"; # 主题页脚文件
    fancyindex_header       "/fancy-theme/header.html"; # 主题头部文件
    fancyindex_ignore       "example.html"; # 忽略显示的文件名称
    fancyindex_ignore       "fancy-theme";  # 忽略显示的目录
    fancyindex_name_length  255;
    fancyindex_time_format  "%Y-%m-%d %H:%M";
}

双击nginx.exe即可运行

已经编译完的nginx下载链接:

https://pan.baidu.com/s/1Kup0RgInlY7BmnHOxqibBw 提取码: vghm

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/840762.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号