从源码安装nginx并且添加fancyindex模块

1

前往nginx官网下载最新nginx源码.

前往Releases · aperezdc/ngx-fancyindex · GitHub下载最新ngx-fancyindex源码.

2

1
2
3
$ cd nginx-?.?.?
$ ./configure \--prefix=/etc/nginx \--sbin-path=/usr/sbin/nginx \--conf-path=/etc/nginx/nginx.conf \--error-log-path=/var/log/nginx/error.log \--http-log-path=/var/log/nginx/access.log \--pid-path=/var/run/nginx.pid \--lock-path=/var/run/nginx.lock \--http-client-body-temp-path=/var/cache/nginx/client_temp \--http-proxy-temp-path=/var/cache/nginx/proxy_temp \--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \--http-scgi-temp-path=/var/cache/nginx/scgi_temp \--user=www \--group=www \--with-file-aio \--with-threads \--with-http_addition_module \--with-http_auth_request_module \--with-http_dav_module \--with-http_flv_module \--with-http_gunzip_module \--with-http_gzip_static_module \--with-http_mp4_module \--with-http_random_index_module \--with-http_realip_module \--with-http_secure_link_module \--with-http_slice_module \--with-http_ssl_module \--with-http_stub_status_module \--with-http_sub_module \--with-http_v2_module \--with-mail \--with-mail_ssl_module \--with-stream \--with-stream_realip_module \--with-stream_ssl_module \--with-stream_ssl_preread_module \--add-module=../ngx-fancyindex-?.?.?
$ make && sudo make install

3

1
2
3
$ sudo /usr/sbin/groupadd -f www
$ sudo /usr/sbin/useradd -g www www
$ sudo nginx -t

4

nginx.conf:

1
2
3
4
5
6
7
8
9
10
charset utf-8,gbk;
location / {
    root html/file;
index index.html index.htm;
fancyindex on;
fancyindex_exact_size off;
fancyindex_name_length 500;
fancyindex_localtime on;
fancyindex_time_format "%Y-%m-%d %H:%M:%S";
}

5

1
$ sudo nginx -s reload