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可以自己起一個喜歡的名字