Ubuntu14.04和Ubuntu12.04都可以
参考来源:
使用nginx搭建简单的文件服务器
nginx配置静态文件服务器
nginx配置文件路径:
/etc/nginx
进入 /etc/nginx目录
文件结构如下:
[email protected]:/etc/nginx$ ls -lth
total K
drwxr-xr-x root root K Oct : sites-available
drwxr-xr-x root root K Oct : sites-enabled
drwxr-xr-x root root K Jun : conf.d
-rw-r--r-- root root Mar fastcgi_params
-rw-r--r-- root root K Mar koi-utf
-rw-r--r-- root root K Mar koi-win
-rw-r--r-- root root K Mar mime.types
-rw-r--r-- root root K Mar naxsi_core.rules
-rw-r--r-- root root Mar naxsi.rules
-rw-r--r-- root root Mar naxsi-ui.conf
-rw-r--r-- root root K Mar nginx.conf
-rw-r--r-- root root Mar proxy_params
-rw-r--r-- root root Mar scgi_params
-rw-r--r-- root root Mar uwsgi_params
-rw-r--r-- root root K Mar win-utf
进入sites-available
有个default文件
首先备份default文件
然后修改default文件如下:
server {
listen default_server;
listen [::]: default_server ipv6only=on;
root /home/hhb/work/catmaid_5d_visualization_annotation/httpdocs/data;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
}
这里root 就是nginx服务器的根目录
其中server_name可以自己起一个喜欢的名字