博客
关于我
阿里云创建二级域名,并在在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/

你可能感兴趣的文章
MySql索引为什么使用B+树
查看>>
MySQL索引为什么是B+树
查看>>
WARNING!VisualDDK wizard was unable to find any DDK/WDK installed on your system.
查看>>
Mysql索引优化
查看>>
MySQl索引创建
查看>>
mysql索引创建及使用注意事项
查看>>
mysql索引创建和使用注意事项
查看>>
MySQL索引原理以及查询优化
查看>>
Mysql索引合并(index merge)导致的死锁问题
查看>>
MySQL索引和查询优化
查看>>
mysql索引底层数据结构和算法
查看>>
Mysql索引底层结构的分析
查看>>
MySQL索引底层:B+树详解
查看>>
Mysql索引总结
查看>>
mysql索引最左匹配原则理解以及常见的sql使用的索引情况的实测
查看>>
Mysql索引类型
查看>>
MySQL索引背后的数据结构及算法原理
查看>>
mysql索引能重复吗_mysql “索引”能重复吗?“唯一索引”与“索引”区别是什么?...
查看>>
MySQL索引详解(IT枫斗者)
查看>>
MySQL索引那些事:什么是索引?为什么加索引就查得快了?
查看>>