更新时间:2022-08-13 08:57:25
nginx配置文件在 nginx-1.8.0\conf\nginx.conf
http {
gzip on;
#静态文件
server {
listen 80;
server_name static.cnblog.com;
location / {
root G:/source/static_cnblog_com;
}
}
#html文件
server {
listen 80;
server_name 127.0.0.1 localhost;
location / {
root G:/source/html/mobile/dist;
index index.html index.htm;
}
}
}
如上图可以配置多个server,这样访问localhost即访问到了 G:/source/html/mobile/dist 目录, 还可以开启gzip,压缩html
bash: nginx: command not found
有可能是你再linux命令行环境下运行了windows命令,
如果你之前是允许 nginx -s reload报错, 试下 ./nginx -s reload
或者 用windows系统自带命令行工具运行