Blog
首页
文档
收藏
关于
  • 在线转换时间戳 (opens new window)
  • 在线压缩图片 (opens new window)
  • Float-Double转二进制 (opens new window)
  • 文件转Hex字符串 (opens new window)

HiuZing

🍑
首页
文档
收藏
关于
  • 在线转换时间戳 (opens new window)
  • 在线压缩图片 (opens new window)
  • Float-Double转二进制 (opens new window)
  • 文件转Hex字符串 (opens new window)
  • Nginx

    • Nginx介绍
    • Nginx安装
    • Nginx配置文件
    • Nginx反向代理
    • Nginx拉取git项目
    • Nginx添加虚拟主机配置文件
      • Nginx添加虚拟主机配置文件
        • 概念
        • 场景
        • 实现步骤
    • Nginx项目自动更新
    • Vue-histroy模式跳转路由404问题
    • GoAccess
    • Nginx负载均衡
  • Docker

  • Server

  • Linux

  • Windows

  • 运维
  • Nginx
HiuZing
2022-12-21
目录

Nginx添加虚拟主机配置文件

# Nginx添加虚拟主机配置文件

# 概念

虚拟主机:在 Web 服务里就是一个独立的网站站点,这个站点对应独立的域名(也可能是IP 或端口),具有独立的程序及资源,可以独立地对外提供服务供用户访问。

# 场景

实现输入不同域名访问不同内容

# 实现步骤

由于是下载安装包,安装在/usr/local路径

安装后在/usr/local/nginx/conf路径下发现配置文件只有一个,当虚拟主机多了就不好管理

将配置文件拆分开来,在/usr/local/nginx/conf路径下

新建一个conf.d文件夹,在/usr/local/nginx/conf/conf.d下创建对应的域名配置文件

touch default.conf
touch xiaojing-dev.nipx.cn.conf
1
2

在/usr/local/nginx/conf下的Nginx.conf文件中进行配置——http块下加一句话就可以了

include /usr/local/nginx/conf/conf.d/*.conf;
1

xiaojing-dev.nipx.cn.conf文件

server {
        listen 80;
        server_name xiaojing-dev.nipx.cn;
        root /var/www/html/xiaojing-dev.nipx.cn;

        location / {
                index index.html index.htm;
        }
}
1
2
3
4
5
6
7
8
9

default.conf

server {
        listen 80;
        server_name default;
        root /usr/local/nginx/html;

        location / {

                        index index.html index.htm;                                                     }
}
1
2
3
4
5
6
7
8
9
上次更新: 2024/08/14, 04:14:33
Nginx拉取git项目
Nginx项目自动更新

← Nginx拉取git项目 Nginx项目自动更新→

最近更新
01
React Native 使用SVG
08-13
02
Docker基础命令
08-04
03
算数逻辑单元
07-30
更多文章>
Theme by Vdoing | Copyright © 2021-2024 WeiXiaojing | 友情链接
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式