标签:nginx
apache默认是开启目录浏览功能的,nginx需要配置下才能实现。
编译安装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