nginx托管静态网站及静态资源基本用法
nginx作为一个具有高性能的http、https、反向代理web服务器,非常适合托管静态资源文件。
它的优点太多,在这里就不一一解说,我们直接看实际应用例子。
1、网站在nginx目录
1.1 默认

目录

网页代码
server{
# 监听的端口
listen 14553;
# 绑定的域名,多个用空格分开即可。
server_name localhost prvt.cool www.prvt.cool;
location / {
root web;
index index2.html;
}
}1.2 别名/虚拟目录

目录

网站目录
server{
# 监听的端口
listen 14553;
# 绑定的域名,多个用空格分开即可。
server_name localhost prvt.cool www.prvt.cool;
location / {
root web;
index index2.html;
}
location /new2 {
alias web/new;
index indexNew.html;
}
}2、网站在其它目录

目录

默认

别名/虚拟目录
server{
# 监听的端口
listen 14553;
# 绑定的域名,多个用空格分开即可。
server_name localhost prvt.cool www.prvt.cool;
location / {
alias E:/demo/web/;
index index2.html;
}
location /new2 {
alias E:/demo/web/new/;
index indexNew.html;
}
}3、代理其它web服务器(静态)站点
这种完全可以通过NGINX直接代理,避免浪费服务器资源,然而也可以作为前置机。
相关推荐
-
「nginx」十、nginx的location配置详解2026-07-04 00:51:45 -

最清晰的mysql体系架构图 ,助你深度掌握MySQL开发管理,赢在大数据时代
最清晰的mysql体系架构图 ,助你深度掌握MySQL开发管理,赢在大数据时代2026-07-04 00:21:47 -
PHP读取Excel内的图片2026-07-03 00:07:41 -
mysql:Otter跨机房数据同步(单向)2026-07-03 00:02:48 -

在windows10系统下搭建IIS+PHP+MYSQL+phpMyAdmin服务器运行环境
在windows10系统下搭建IIS+PHP+MYSQL+phpMyAdmin服务器运行环境2026-07-02 00:15:08