Nginx 搭建静态文件服务器
修改 nginx.conf 配置
找到 Nginx 配置文件 nginx.conf 的路径:
vim /usr/local/webserver/nginx/conf/nginx.conf
在 http {} 中添加 server {}(server {}:定义一个虚拟主机,server可以出现一次或多次):
http {
......
......
server {
#listen 8000;
listen 192.168.16.111:8080;
server_name 192.168.16.111 alias another.alias;
location / {
root /home/OTPMobile/android;
access_log on;
autoindex on;
}
}
server {
listen 192.168.16.111:9999;
server_name 192.168.16.111 alias another.alias;
location / {
root /home/OTPMobile/ios;
access_log on;
autoindex on;
}
}
......
......
}
重启 Nginx 服务
cd /usr/local/webserver/nginx/sbin
./nginx -s reload
./nginx -s reopen

本文详细介绍了如何通过修改 Nginx 配置文件 nginx.conf,设置虚拟主机,来搭建静态文件服务器。配置完成后,通过重启 Nginx 服务,可以成功访问在指定目录下存放的静态资源。
最低0.47元/天 解锁文章
578

被折叠的 条评论
为什么被折叠?



