博客
关于我
阿里云创建二级域名,并在在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模糊查询like效率,以及更高效的写法
查看>>
MySQL死锁套路:一次诡异的批量插入死锁问题分析
查看>>
Mysql死锁问题Deadlock found when trying to get lock;try restarting transaction
查看>>
mysql每个数据库的最大连接数_MySQL数据库最大连接数
查看>>
Mysql流程控制结构,if函数、case结构、if结构、循环结构
查看>>
mysql添加外网访问权限
查看>>
mysql添加用户
查看>>
MySQL添加用户、删除用户与授权
查看>>
mysql添加用户及权限
查看>>
Mysql添加用户并授予只能查询权限
查看>>
mysql添加用户权限报1064 - You have an error in your SQL syntax问题解决
查看>>
mysql添加索引
查看>>
mysql添加表注释、字段注释、查看与修改注释
查看>>
mysql清理undo线程_MySQL后台线程的清理工作
查看>>
mysql清空带外键的表
查看>>
MySQL清空表数据
查看>>
mysql源码安装
查看>>
Mysql源码安装过程中可能碰到的问题
查看>>
MySQL灵魂16问,你能撑到第几问?
查看>>
MySQL灵魂拷问:36题带你面试通关
查看>>