On 10 minutes a cloud of static Web Hosting

Share this article from micro-channel public number: Tencent cloud storage (Watch a surprise)


Static Website: Unlike dynamic website, it is the only contain static content (such as images, audio, video, HTML, CSS, JS) site, server-side dynamic rendering the page. So how should use static website hosting it?

Today and share with you, "" fool "to build a static website hosting tours."

  Users can Tencent cloud object storage hosting static website (hereinafter referred to as COS), visitors can custom domain name (such as www.example.com)

Access hosted a static website. Here are the steps:

1620

a

    The following is a practice, will be used related services:

  • Domain Name Registration : before hosting static websites, you need to register a domain name, such as www.example.com.

  • Object storage COS : COS use to create buckets, upload web content will be stored in the bucket.

  • Content Delivery Network CDN : CDN combination of analytic and cloud services, making the domain name and web content while bound, static website can also speed up and reduce access latency and improve availability.

  • Cloud resolution : use cloud resolution, to achieve the purpose of using custom domain names static site.

Description:

All steps in this guide use the domain www.example.com as an example. Please use your own domain name domain name to replace this practice.

1620

4 steps to get static Web Hosting

01

    The registered domain name for the record

  Domain name registration is the basis for the establishment of any service on the Internet. After registering the domain name, but also for the record, normal access to the site. Proceed according to your situation:

  • Registered domain names and record, this step may be skipped, performed in step 2;

  • Registered domain names but for the record, your domain name registration;

  • Domain name is not registered, please register a domain name, then the domain name for the record;

02

    Create a bucket and upload content

  After the completion of domain name registration and for the record, you need to perform the following tasks in COS console to create and configure site content:

  • Create a bucket;

  • Configuring buckets and upload content;

  2-1, create a bucket

  Please log in using the console COS Tencent cloud account, create a corresponding bucket for your website, buckets for storing data, you can website content stored in a bucket.

  If you first use COS, you can create a bucket by an overview of the console's interface directly, or create buckets in the bucket list navigation bar.

  2-2, configure bucket and uploads

Open buckets static website settings by:

1) Log COS console, in the left menu bar, click [] bucket list, find the bucket just created, click on the right side of the [configuration management]

1620

  2) find a static Web site, click Edit, the current state is set to ON, the other being set as default and click Save.

1620

  3) Upload your site content to have created a good bucket. The contents stored in the bucket can be text files, photos, videos, whatever you want hosted. If you have not build websites, simply click here to create a practice file.

  For example, you can create a file using the following HTML, and upload it to the bucket. Home page file name is usually index.html. In a subsequent step, you will be offered this document as an index file website. Set up

<!DOCTYPE html><html>
    <head>
        <title>Hello COS!</title>
        <meta charset="utf-8">
    </head>
    <body>
        <p>欢迎使用&nbspCOS&nbsp的静态网站功能。</p>
        <p>这是首页!</p>
    </body></html>

注意: 开启静态网站功能后,当用户访问任何不带文件指向的一级目录时,COS默认优先匹配对应存储桶目录下index.html,其次为index.htm,若无此文件,则返回404。

03

  绑定自定义域名

  为了加速访问,我们推荐将域名绑定为自定义加速域名,借助腾讯云 CDN 加速您的静态网站,使网站访客获取更好的浏览体验。

  3-1、域名添加

  1) 登录COS控制台 ,在左侧菜单栏中,单击【存储桶列表】,单击存储网站内容的存储桶并进入。

  2) 在左侧二级菜单栏中,单击【域名管理】,进入域名管理页面,单击【自定义加速域名】下的【添加域名】,进入可配置状态:

  域名:输入您已购买的自定义域名;

  源站类型:选择静态网站源站;

 回源鉴权:勾选,然后单击保存即可;

1620

3) 单击保存后,按照提示继续添加【CDN服务授权】。

1620

在CDN服务授权弹窗中,单击确定即可。

1620

   4) Wait a few minutes, waiting for the domain name on the line to complete the deployment. Then copy the corresponding CNAME record, then the following steps.

1620

3-2, DNS

  If you use a third-party service providers to register domain names, add a CNAME record and point to CNAME step 3.1 corresponding to your custom domain name service provider.

  If you use Tencent cloud resolution service, please refer to the following operation:

  1) Log cloud resolution console, find your domain name, click on the right side of [resolution].

1620

  2) Click the Add Record button.

    Host record: www;

    Record Type: CNAME;

    Record values: CNAME records corresponding to step 3.1;

    Then click Save to complete the addition.

1620

04

    Testing and certification

  After the above steps, can be accessed in the browser address bar enter the domain to verify the results of practice to www.example.com, for example:

  • http://www.example.com - return to the index page (index.html) bucket named example of.

  • http://www.example.com/test.html (non-existent file) - Returns 404 tips. If you need a custom error documents can be opened [2.2] Set static website is further provided documentation] [an error, the file does not exist at this time access to the documents specified error is displayed in step.

Note: In some cases, you may need to clear your browser's cache to see the expected results.


1620

Sweep the attention surprises


Guess you like

Origin blog.51cto.com/14626080/2456403