首页 > 其他 > 详细

Nginx开启目录浏览

时间:2016-01-04 18:23:26      阅读:225      评论:0      收藏:0      [点我收藏+]

apache默认是开启目录浏览功能的,nginx需要配置下才能实现。


  1. 编译安装nginx

在官网下载最新版本的nginx,编译安装

[root@nginx ~]# yum -y install pcre pcre-devel

[root@nginx ~]# wget http://nginx.org/download/nginx-1.9.9.tar.gz

[root@nginx ~]# tar xf nginx-1.9.9.tar.gz

[root@nginx ~]# ./configure --prefix=/usr/local/nginx

[root@nginx ~]# make && make install


2.打开配置文件,在server段添加代码

[root@nginx ~]# vi /usr/local/nginx/conf/nginx.conf


    server {

        listen       80;

        server_name  localhost;

        root /var/www/html/;

        charset utf-8;


        location / {

            autoindex on; #开启功能

            autoindex_exact_size off; #off显示文件大小,单位是kB、MB、GB;on显示bytes

            autoindex_localtime on; #off显示的文件时间为GMT时间;on显示是服务器时间;

            index  index.html index.htm;

        }

        }


3.查看配置文件

[root@nginx ~]# /usr/local/nginx/sbin/nginx -t

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful


4.启动nginx服务

[root@nginx ~]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf


5.创建浏览目录

[root@nginx ~]# mkdir /var/www/html/nginx


技术分享

本文出自 “卡卡西” 博客,请务必保留此出处http://whnba.blog.51cto.com/1215711/1731413

Nginx开启目录浏览

原文:http://whnba.blog.51cto.com/1215711/1731413

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!