# 安装nginx: sudo apt-get install nginx # 配置一下nginx的启动用户: vi /etc/nginx/nginx.conf # 把user从www-data改为自己的用户am-server user am-server; :wq vi /etc/nginx/sites-available/default # 更改根目录和location: server { listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6
root /home/am-server/data; index index.html index.htm;
# Make site accessible from http://localhost/ server_name localhost;
location / { # First attempt to serve request as file, then # as directory, then fall back to index.html try_files $uri $uri/ /index.html; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location /soft{ autoindex on; allow all; } } 这里我顺手把index文件也拷进了data/ cp /usr/share/nginx/www/index.html /data #保存之后重启nginx即可: service nginx restart