Domain name binding cloud host

The first domain name binding to the cloud host was successful!

Local configuration domain name process

1. Create a test folder
2. Create an index.php file

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

3. Create an nginx configuration

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;
    }

Its function is probably that when listening to the entry of local.test.com, it will automatically enter the corresponding target folder.

restart nginx

$ sudo nginx -s stop
$ sudo nginx

At this time, entering local.test.com did not work.

Because local.test.com does not point to this machine, it also needs to be added to a host.

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

At this time, after accessing local.test.com and nginx, it will execute the code in index.php.

Alibaba Cloud Domain Name Binding Project

$ 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

At this time, Alibaba Cloud has set the hosts file to point to that ip.

At this time, nginx needs to do some processing and assign this ip to the corresponding directory.

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;
}

Point to the test directory and create a new index.php in the test directory

input content,

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

Restart the server's nginx, and you're done.

The hosts in the server do not need to be configured, because the Aliyun domain name has already been resolved. It is the widest dns. You can let all the computers in the world visit www.jiqing9006.top to the computer with this ip.

Another point is that it is best to file a domain name on a case-by-case basis, otherwise, when visiting, it will always prompt that it has not been filed.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324629825&siteId=291194637
Recommended