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
访问静态服务器
接下来,我们可以在 /home/OTPMobile/android
和 /home/OTPMobile/ios
目录中放入一些文件,然后在浏览器中访问 IP:8080 和 IP:9999: