Ubuntu14.04和Ubuntu12.04都可以
参考来源:
使用nginx搭建简单的文件服务器
nginx配置静态文件服务器
nginx配置文件路径:
/etc/nginx
进入 /etc/nginx目录
文件结构如下:
hhb@ubuntu:/etc/nginx$ ls -lthtotal 64Kdrwxr-xr-x 2 root root 4.0K Oct 20 00:10 sites-availabledrwxr-xr-x 2 root root 4.0K Oct 19 23:37 sites-enableddrwxr-xr-x 2 root root 4.0K Jun 2 23:16 conf.d-rw-r--r-- 1 root root 911 Mar 5 fastcgi_params-rw-r--r-- 1 root root 2.3K Mar 5 koi-utf-rw-r--r-- 1 root root 1.8K Mar 5 koi-win-rw-r--r-- 1 root root 2.1K Mar 5 mime.types-rw-r--r-- 1 root root 5.2K Mar 5 naxsi_core.rules-rw-r--r-- 1 root root 287 Mar 5 naxsi.rules-rw-r--r-- 1 root root 222 Mar 5 naxsi-ui.conf.1.4.1-rw-r--r-- 1 root root 1.6K Mar 5 nginx.conf-rw-r--r-- 1 root root 180 Mar 5 proxy_params-rw-r--r-- 1 root root 465 Mar 5 scgi_params-rw-r--r-- 1 root root 532 Mar 5 uwsgi_params-rw-r--r-- 1 root root 3.0K Mar 5 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, then31 # as directory, then fall back to displaying a 404.32 try_files $uri $uri/ =404;33 # Uncomment to enable naxsi on this location34 # include /etc/nginx/naxsi.rules35 autoindex on;36 autoindex_exact_size on;37 autoindex_localtime on;38 }
这里root 就是nginx服务器的根目录
其中server_name可以自己起一个喜欢的名字