zoukankan      html  css  js  c++  java
  • 域名绑定云主机

    第一次域名绑定云主机成功!

    本地配置域名流程

    1.创建一个test文件夹
    2.创建一个index.php文件

    <?php
        echo date("Y-m-d H:i:s")." 来自本地的时间服务。";
    ?>
    

    3.创建一个nginx配置

    server
        {
            listen 80;
            #listen [::]:80 default_server ipv6only=on;
            server_name local.test.com;
            index index.html index.htm index.php;
            root  /home/wwwroot/default/test;
    
            #error_page   404   /404.html;
            include enable-php-pathinfo.conf;
    
            location /nginx_status
            {
                stub_status on;
                access_log   off;
            }
    
            location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
            {
                expires      30d;
            }
    
            location ~ .*.(js|css)?$
            {
                expires      12h;
            }
    
            location ~ /.
            {
                deny all;
            }
    
            access_log  /home/wwwlogs/access.log;
        }
    
    

    它的作用大概就是,监听到local.test.com进入的时候,就会自动进入相应的目标文件夹下。

    重启nginx

    $ sudo nginx -s stop
    $ sudo nginx
    

    这个时候输入local.test.com并没有起作用。

    因为local.test.com并没有指向本机,还需要一个hosts中加入。

    127.0.0.1   local.test.com
    
    $ ping local.test.com
    PING local.test.com (127.0.0.1) 56(84) bytes of data.
    64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.075 ms
    64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.037 ms
    64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.057 ms
    64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.058 ms
    
    

    这个时候访问,local.test.com,nginx监听到之后,就执行index.php中的代码了。

    阿里云域名绑定项目

    $ ping www.jiqing9006.top
    PING www.jiqing9006.top (139.224.55.222) 56(84) bytes of data.
    64 bytes from 139.224.55.222: icmp_seq=1 ttl=51 time=24.4 ms
    64 bytes from 139.224.55.222: icmp_seq=2 ttl=51 time=23.8 ms
    64 bytes from 139.224.55.222: icmp_seq=3 ttl=51 time=24.6 ms
    

    这个时候相当于阿里云已经设置了hosts文件指向那个ip。

    这个时候,就需要nginx做一些处理,将这个ip指定到相应的目录下了。

    server{
            listen 80;
            server_name www.jiqing9006.top;
            index index.html index.htm index.php;
            root  /home/wwwroot/default/test;
    
            #error_page   404   /404.html;
            #include enable-php.conf;
            include enable-php-pathinfo.conf;
            location /nginx_status
            {
                stub_status on;
                access_log   off;
            }
    
            location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
            {
                expires      30d;
            }
    
            location ~ .*.(js|css)?$
            {
                expires      12h;
            }
    
            location ~ /.
            {
                deny all;
            }
    
            access_log  /home/wwwlogs/hotel/access.log  access;
    }
    
    

    指向test目录下,在test目录下新建一个index.php

    输入内容,

    <?php
    echo date("Y-m-d H:i:s");
    

    重启服务器的nginx,就可以了。

    服务器中的hosts并不需要做配置,因为阿里云域名已经做了解析了。它是最宽阔的dns。可以让全球的电脑访问www.jiqing9006.top都会到这个ip的电脑上。

    还有一点就是,域名最好去备个案,否则访问的时候,总是提示未备案。

  • 相关阅读:
    《编程珠玑番外篇-O 中间语言和虚拟机漫谈》
    《编译原理之美》笔记——后端部分
    《编译原理之美》笔记——前端部分
    《从语言编译器源码入手,编译原理该这么学》
    知识图谱简介
    支持向量机原理讲解(一)
    一个完整的机器学习项目在Python中演练(四)
    多GPU使用详解
    数据可视化
    详解谱聚类原理
  • 原文地址:https://www.cnblogs.com/jiqing9006/p/8904962.html
Copyright © 2011-2022 走看看