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

你可能感兴趣的文章
Nginx 学习(一):Nginx 下载和启动
查看>>
nginx 常用指令配置总结
查看>>
Nginx 常用配置清单
查看>>
nginx 常用配置记录
查看>>
nginx 开启ssl模块 [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx
查看>>
Nginx 我们必须知道的那些事
查看>>
Nginx 源码完全注释(11)ngx_spinlock
查看>>
Nginx 的 proxy_pass 使用简介
查看>>
Nginx 的 SSL 模块安装
查看>>
Nginx 的优化思路,并解析网站防盗链
查看>>
Nginx 的配置文件中的 keepalive 介绍
查看>>
nginx 禁止以ip形式访问服务器
查看>>
Nginx 结合 consul 实现动态负载均衡
查看>>
Nginx 负载均衡与权重配置解析
查看>>
Nginx 负载均衡详解
查看>>
nginx 配置 单页面应用的解决方案
查看>>
nginx 配置https(一)—— 自签名证书
查看>>
nginx 配置~~~本身就是一个静态资源的服务器
查看>>
Nginx 配置服务器文件上传与下载
查看>>
Nginx 配置清单(一篇够用)
查看>>