微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Ubuntu搭建简单nginx文件服务器

Ubuntu14.04和Ubuntu12.04都可以
参考来源:
使用nginx搭建简单的文件服务器

nginx配置静态文件服务器

Nginx配置文件路径:

/etc/Nginx

进入 /etc/Nginx目录
文件结构如下:

hhb@ubuntu:/etc/Nginx$ ls -lth
total 64K
drwxr-xr-x 2 root root 4.0K Oct 20 00:10 sites-available
drwxr-xr-x 2 root root 4.0K Oct 19 23:37 sites-enabled
drwxr-xr-x 2 root root 4.0K Jun  2 23:16 conf.d
-rw-r--r-- 1 root root  911 Mar  5  2014 fastcgi_params
-rw-r--r-- 1 root root 2.3K Mar  5  2014 koi-utf
-rw-r--r-- 1 root root 1.8K Mar  5  2014 koi-win
-rw-r--r-- 1 root root 2.1K Mar  5  2014 mime.types
-rw-r--r-- 1 root root 5.2K Mar  5  2014 naxsi_core.rules
-rw-r--r-- 1 root root  287 Mar  5  2014 naxsi.rules
-rw-r--r-- 1 root root  222 Mar  5  2014 naxsi-ui.conf.1.4.1
-rw-r--r-- 1 root root 1.6K Mar  5  2014 Nginx.conf
-rw-r--r-- 1 root root  180 Mar  5  2014 proxy_params
-rw-r--r-- 1 root root  465 Mar  5  2014 scgi_params
-rw-r--r-- 1 root root  532 Mar  5  2014 uwsgi_params
-rw-r--r-- 1 root root 3.0K Mar  5  2014 win-utf

进入sites-available
有个default文件
首先备份default文件

cp default default.backup

然后修改default文件如下:

20 server {
 21         listen 80 default_server;
 22         listen [::]:80 default_server ipv6only=on;
 23 
 24         root /home/hhb/work/catmaid_5d_visualization_annotation/httpdocs/data;
 25 
 26         # Make site accessible from http://localhost/
 27         server_name localhost;
 28 
 29         location / {
 30                 # First attempt to serve request as file,then
 31                 # as directory,then fall back to displaying a 404.
 32                 try_files $uri $uri/ =404;
 33                 # Uncomment to enable naxsi on this location
 34                 # include /etc/Nginx/naxsi.rules
 35                 autoindex on;
 36                 autoindex_exact_size on;
 37                 autoindex_localtime on;
 38         }

这里root 就是Nginx服务器的根目录 其中server_name可以自己起一个喜欢的名字

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐