博客
关于我
阿里云创建二级域名,并在在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(4)运算符 | 关联查询详解
查看>>
MySQL(5)条件查询 | 单行函数 | 事务详解
查看>>
Mysql,group by分组查询、order by排序查询、join连接查询、union联合查询
查看>>
Mysql,sql文件导入和导出
查看>>
MYSQL:int类型升级到bigint,对PHP开发语言影响
查看>>
Mysql:mysql 5.X 报错 ERROR 1193 (HY000): Unknown system variable ‘validate_password_length‘
查看>>
MySQL:MySQL执行一条SQL查询语句的执行过程
查看>>
Mysql:SQL性能分析
查看>>
mysql:SQL按时间查询方法总结
查看>>
MySQL:什么样的字段适合加索引?什么样的字段不适合加索引
查看>>
MySQL:判断逗号分隔的字符串中是否包含某个字符串
查看>>
MySQL:某个ip连接mysql失败次数过多,导致ip锁定
查看>>
MySQL:索引失效场景总结
查看>>
Mysql:避免重复的插入数据方法汇总
查看>>
MyS中的IF
查看>>
M_Map工具箱简介及地理图形绘制
查看>>
m_Orchestrate learning system---二十二、html代码如何变的容易
查看>>
M×N 形状 numpy.ndarray 的滑动窗口
查看>>
m个苹果放入n个盘子问题
查看>>
n = 3 , while n , continue
查看>>