如何配置nginx作为静态文件托管服务器
更新时间:2024年01月31日 15:01:24 作者:andy_lau_andy
这篇文章主要介绍了如何配置nginx作为静态文件托管服务器的相关资料,下载nginx在windows上是个压缩包,解压后,使用命令行输入nginx进行启动,感兴趣的朋友跟随小编一起看看吧
下载nginx
windows上是个压缩包
解压后, 使用命令行输入 nginx 进行启动
nginx -s stop 进行停止nginx -s status 查看状态
可以配置一下环境变量
主要是配置文件, windows的nginx配置文件在 conf文件夹下
在http标签下 添加如下配置

其他地方不用更改,保持原样即可,
以下是整个配置文件的参考
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name example.com;
root G:\media;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
}到此这篇关于配置nginx作为静态文件托管服务器的文章就介绍到这了,更多相关nginx静态文件托管服务器内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
Nginx could not build the server_names_hash 错误的解决办法
这篇文章主要介绍了Nginx could not build the server_names_hash 错误的解决办法,需要的朋友可以参考下2014-03-03
Kubernetes中Nginx服务启动失败排查流程分析(Error: ImagePullBackOff)
这篇文章主要介绍了Kubernetes中Nginx服务启动失败排查流程(Error: ImagePullBackOff),本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2023-03-03


最新评论