博客
关于我
阿里云创建二级域名,并在在nginx中配置二级域名访问
阅读量:137 次
发布时间:2019-02-26

本文共 1222 字,大约阅读时间需要 4 分钟。

创建二级域名及Nginx配置指南

一、创建二级域名

在创建并配置二级域名之前,需先完成以下步骤:

  • 进入阿里云的域名管理界面

    访问阿里云管理平台,进入“域名管理”模块。

  • 新建二级域名

    在域名列表中,点击“新增解析”,填写所需的二级域名(如mp.xxx.cn),完成后保存。

  • 配置DNS解析

    确保新建的二级域名已正确解析到阿里云的服务器IP地址。

  • 验证域名访问

    在浏览器中输入二级域名地址(如http://mp.xxx.cn),确认访问无误。

  • 二、Nginx配置指南

    接下来,将二级域名配置到Nginx服务器中:

  • 安装Nginx(以CentOS7为例)

    • 添加Nginx源:
      sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
    • 更新源并安装:
      yum search nginxyum install -y nginx
    • 启用并启动服务:
      sudo systemctl start nginx.servicesudo systemctl enable nginx.service
    • 常用命令:
      nginx -t # 测试配置systemctl is-enabled nginx.service # 查询服务状态
  • 配置Nginx服务器块

    /etc/nginx/conf.d目录下创建新的配置文件mp.xxx.cn.conf,内容如下:

    server {    listen 80;    server_name mp.xxx.cn;    # 静态文件托管    location / {        root /var/lib/jenkins/workspace/-admin/dist;        try_files $uri $uri/ /index.html;        index index.html index.htm;    }    # 前端路由处理    location @router {        rewrite ^.* /index.html last;    }    # API代理    location /api/v1 {        proxy_pass http://localhost:5000/api/v1;    }}
  • 加载配置文件

    使新的配置生效:

    sudo nginx -s reload
  • 注意事项

    • 域名解析:确保DNS记录已正确指向阿里云服务器IP地址。
    • 服务器权限:确认Nginx服务有权限访问静态文件目录/usr/share/nginx/html
    • 端口配置:如API服务运行于非标准端口(如5000),需在Nginx配置中相应设置。

    通过以上步骤,您已成功创建并配置二级域名及Nginx服务器,访问二级域名地址即可查看内容。

    转载地址:http://ijvf.baihongyu.com/

    你可能感兴趣的文章
    No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
    查看>>
    No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
    查看>>
    No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
    查看>>
    No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
    查看>>
    No module named cv2
    查看>>
    No module named tensorboard.main在安装tensorboardX的时候遇到的问题
    查看>>
    No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
    查看>>
    No new migrations found. Your system is up-to-date.
    查看>>
    No qualifying bean of type XXX found for dependency XXX.
    查看>>
    No resource identifier found for attribute 'srcCompat' in package的解决办法
    查看>>
    No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
    查看>>
    NO.23 ZenTaoPHP目录结构
    查看>>
    NO32 网络层次及OSI7层模型--TCP三次握手四次断开--子网划分
    查看>>
    NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
    查看>>
    Node JS: < 一> 初识Node JS
    查看>>
    Node-RED中使用JSON数据建立web网站
    查看>>
    Node-RED中使用json节点解析JSON数据
    查看>>
    Node-RED中使用node-red-browser-utils节点实现选择Windows操作系统中的文件并实现图片预览
    查看>>
    Node-RED中使用Notification元件显示警告讯息框(温度过高提示)
    查看>>
    Node-RED中实现HTML表单提交和获取提交的内容
    查看>>