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

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

一、创建二级域名

  • 1、在阿里云上(获取别的域名商)处点击域名

在这里插入图片描述

  • 2、在域名列表中点击解析

    在这里插入图片描述

  • 3、新增解析

    在这里插入图片描述

  • 4、新增二级域名

    在这里插入图片描述

  • 5、解析生产后正常在浏览器访问地址

    # xxx是你的域名mp.xxx.cn

二、在nginx中配置你的二级域名

  • 1、本人是centos服务器,使用yum方式安装nginx

    • 添加源

      # 默认情况Centos7中无Nginx的源,最近发现Nginx官网提供了Centos的源地址。因此可以如下执行命令添加源:sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
    • 查看源是否安装成功

      yum search nginx
    • 安装

      yum install -y nginx
    • 常见命令

      sudo systemctl start nginx.servicesudo systemctl enable nginx.servicenginx -t # 检查配置项目systemctl is-enabled servicename.service #查询服务是否开机启动systemctl enable *.service #开机运行服务systemctl disable *.service #取消开机运行systemctl start *.service #启动服务systemctl stop *.service #停止服务systemctl restart *.service #重启服务systemctl reload *.service #重新加载服务配置文件systemctl status *.service #查询服务运行状态systemctl --failed #显示启动失败的服务
    • 文件目录

      • 1.静态文件目录/usr/share/nginx/html
      • 2.配置文件目录/etc/nginx
  • 2、在/etc/nginx/conf.d目录下创建一个文件

    # xxx是你的域名mp.xxx.conf
  • 3、配置你的conf文件

    server {       listen 80;  server_name 你的二级域名;  # 配置静态文件  location /{                                                                                                             #default_type text/html;                      #return 200 'doc';              root /var/lib/jenkins/workspace/-admin/dist;    try_files $uri $uri/ @router;    index index.htm index.html;                                                                              }                                                                                                                location @router {                                                                                                    	rewrite ^.*$ /index.html last; # 关键一句,处理前端项目vue,react刷新404问题                                                                }   # 配置接口  location /api/v1 {                                                                                                    	proxy_pass http://localhost:5000/api/v1;                                                                 }      }

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

你可能感兴趣的文章
NFS共享文件系统搭建
查看>>
nfs复习
查看>>
NFS安装配置
查看>>
NFS的安装以及windows/linux挂载linux网络文件系统NFS
查看>>
NFS的常用挂载参数
查看>>
NFS网络文件系统
查看>>
NFS远程目录挂载
查看>>
nft文件传输_利用remoting实现文件传输-.NET教程,远程及网络应用
查看>>
NFV商用可行新华三vBRAS方案实践验证
查看>>
ng build --aot --prod生成文件报错
查看>>
ng 指令的自定义、使用
查看>>
nghttp3使用指南
查看>>
Nginx
查看>>
nginx + etcd 动态负载均衡实践(三)—— 基于nginx-upsync-module实现
查看>>
nginx + etcd 动态负载均衡实践(二)—— 组件安装
查看>>
nginx + etcd 动态负载均衡实践(四)—— 基于confd实现
查看>>
Nginx + Spring Boot 实现负载均衡
查看>>
Nginx + uWSGI + Flask + Vhost
查看>>
Nginx - Header详解
查看>>
Nginx - 反向代理、负载均衡、动静分离、底层原理(案例实战分析)
查看>>