nginx 文件目录访问
yum install nginx-* nginx -y
nginx.conf 设置
[root@huayun ~]# cat /etc/nginx/nginx.conf
user root;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
gzip_min_length 1k;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript ;
gzip_vary on;
gzip_http_version 1.1;
gzip_disable "MSIE [1-6]\.";
include /etc/nginx/conf.d/*.conf;
}
## file.conf 文件设置
[root@huayun ~]# cat /etc/nginx/conf.d/file.conf
server {
listen 8081;
server_name localhost;
charset utf-8;
location / {
alias /data/www/file/;
default_type text/plain;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}
}
[root@huayun ~]#
## 启动服务
nginx -t
systemctl restart nginx
## 测试