amazon s3_在Amazon S3上托管网站

news/2024/5/21 1:15:51/文章来源:https://blog.csdn.net/culuo8053/article/details/107931826

amazon s3

Everyone knows that Amazon S3 is great for storing files. It's fast, inexpensive, and easy to setup. What you may not realize is that you can also host static websites on this robust platform.

众所周知, Amazon S3非常适合存储文件。 它快速,便宜且易于设置。 您可能没有意识到的是,您还可以在此强大的平台上托管静态网站

What is a static website? In short, it's a website comprised of only HTML, CSS, and/or JavaScript. That means server-side scripts aren't supported, so if you want to host a Rails or PHP app, you'll need to look elsewhere. For simpler purposes, welcome to the wonderful world of hosting websites on S3!

什么是静态网站? 简而言之,这是一个仅包含HTML,CSS和/或JavaScript的网站。 这意味着不支持服务器端脚本,因此,如果您想托管Rails或PHP应用程序,则需要在其他地方查找。 为了简单起见,欢迎来到S3托管网站的美好世界!

创建一个桶 (Creating a Bucket)

If you don't already have one, the first thing you'll need to do is sign up for an Amazon Web Services (AWS) account. It doesn't cost anything to sign up, but keep in mind you will need to pay for storage and transfer fees once you start putting objects on S3. (Don't worry, it's cheap!)

如果您还没有,那么首先需要注册一个Amazon Web Services (AWS)帐户。 注册不需要任何费用,但是请记住,一旦开始在S3上放置对象,您将需要支付存储和转移费用。 (不用担心, 它很便宜! )

Once you create an account, you'll have access to the AWS Management Console.

创建帐户后,您将可以访问AWS管理控制台 。

The AWS Management Console

This is where you'll go to create your first bucket. A bucket is similar to a folder on your hard drive, except it's in the cloud and it has virtually unlimited storage. There are a few things you need to know about buckets before creating one:

这是您创建第一个存储桶的地方 。 存储桶类似于硬盘驱动器上的文件夹,但存储桶位于云中,并且几乎具有无限的存储空间。 在创建存储桶之前,您需要了解以下几点:

  • Bucket names need to be unique across the entire S3 platform

    存储桶名称在整个S3平台上必须唯一
  • You can create a bucket in one of many supported regions around the world

    您可以在全球许多受支持的地区之一中创建存储分区

  • If you want to use a custom domain, your bucket name will need to be the same as your domain name

    如果您想使用自定义域名,则您的存储桶名称必须与域名相同

To create a bucket, navigate to S3 in the AWS Management Console and hit Create Bucket. You'll be prompted to enter a name and a region.

要创建存储桶,请在AWS管理控制台中导航到S3并点击Create Bucket 。 系统将提示您输入名称和区域。

Creating a bucket in the AWS console

If you plan on using your own domain/subdomain, use that for your bucket name. For the region, pick the one closest to you and hit Create. With any luck, you'll see your new bucket appear in the console.

如果您打算使用自己的域/子域,则将其用作存储桶名称。 对于该区域,选择距离您最近的区域,然后点击创建 。 运气好的话,您会看到新存储桶出现在控制台中。

Viewing your bucket in the AWS console

The only thing left to do is enable Static Website Hosting. Just select it from the panel on the right.

剩下要做的就是启用“ 静态网站托管” 。 只需从右侧面板中选择它即可。

Static Website Hosting settings in the AWS console

Make sure you set the Index Document to index.html. You can also set an error page if you want. When you're done, hit Save.

确保将索引文档设置为index.html 。 您也可以根据需要设置错误页面。 完成后,点击保存

Well, that was easy. Now let's upload the homepage!

好吧,那很容易。 现在,让我们上传主页!

上载您的首页 (Uploading Your First Page)

One nice thing about the AWS Management Console is that you can upload files to your bucket right from your browser. Let's start by creating one called index.html. This will be the contents of the homepage:

AWS管理控制台的一件好事是,您可以直接从浏览器将文件上传到存储桶。 让我们开始创建一个名为index.html 。 这将是主页的内容:

<!doctype html>
<html>
<head>
<title>Hello, S3!</title>
<meta name="description" content="My first S3 website">
<meta charset="utf-8">
</head>
<body>
<h1>My first S3 website</h1>
<p>I can't believe it was that easy!</p>
</body>
</html>

To upload it, select your new bucket and hit Upload.

要上传,请选择您的新存储桶,然后点击上传

Uploading a file in the AWS console

Once you've uploaded index.html, it will appear in your bucket. However, you won't be able to see it in your browser yet because everything in S3 is private by default.

上传index.html ,它将显示在您的存储桶中。 但是,由于默认情况下S3中的所有内容都是私有的,因此您将无法在浏览器中看到它。

To make it public, right-click on index.html and select Make Public. (Remember to do this for any other files you upload to your website!)

要使其公开,请右键单击index.html然后选择公开 。 (请记住对您上传到网站的任何其他文件执行此操作!)

Now that your homepage is visible to the world, it's time to test everything out! Select index.html in the console and go to the Properties tab.

既然您的主页对全世界都是可见的,那么现在该测试所有内容了! 在控制台中选择index.html ,然后转到“ 属性”选项卡。

Getting the link to your file in the AWS console

Clicking the link will take you to your new homepage.

单击该链接将带您到新的主页。

Homepage Preview

You'll notice that the address bar shows s3.amazon.com. This is the default URL for objects stored on Amazon S3. Let's setup a custom domain and really turn this into a website.

您会注意到地址栏显示s3.amazon.com 。 这是存储在Amazon S3上的对象的默认URL。 让我们设置一个自定义域,并将其真正变成一个网站。

使用您自己的域 (Using Your Own Domain)

If your bucket name is the same as your domain/subdomain name, you can point it to your new website by creating a CNAME record in your domain's DNS settings. It should look something like this:

如果存储桶名称与域名/子域名相同,则可以通过在域名的DNS设置中创建CNAME记录来将其指向新网站。 它看起来应该像这样:

Domain: example.com
Type: CNAME
Target: s3.amazonaws.com.

Remember to replace example.com with your own domain. After the DNS propagates (which could take up to 24 hours), you should be able to see your website by visiting the domain in a browser. If it doesn't show up, make sure your bucket name is exactly the same as your domain/subdomain and double check your DNS settings.

请记住用您自己的域替换example.com 。 DNS传播后(最多可能需要24小时),您应该能够通过在浏览器中访问域来查看您的网站。 如果未显示,请确保您的存储桶名称您的域/子域完全相同,然后仔细检查您的DNS设置。

如何编辑您的S3网站 (How to Edit Your S3 Website)

Now that your website is up and running, you'll probably want to make changes to it. Alas, you can't install something like WordPress on Amazon S3. So how do you manage content?

现在您的网站已启动并正在运行,您可能需要对其进行更改。 las,您无法在Amazon S3上安装WordPress之类的东西。 那么您如何管理内容?

Shameless plug: I recommend Surreal CMS. It links up to just about any site using FTP, SFTP, or Amazon S3 and it's dead simple to integrate. Take that homepage, for example. Let's make the entire thing editable:

无耻的插件:我建议使用Surreal CMS 。 它可以使用FTP,SFTP或Amazon S3链接到几乎任何站点,并且集成起来非常简单。 以该主页为例。 让我们将整个事情变成可编辑的:

<!doctype html>
<html>
<head>
<title>Hello, S3!</title>
<meta name="description" content="My first S3 website">
<meta charset="utf-8">
</head>
<body>
<div id="content" class="editable">
<h1>My first S3 website</h1>
<p>I can't believe it was that easy!</p>
</div>
</body>
</html>

Notice how I've wrapped the content in a <div> and given it a class called editable? That pretty much sums up the integration process. You can make just about any HTML element editable this way.

注意我如何将内容包装在<div>并给它一个名为editable的类? 这几乎可以概括集成过程 。 您可以通过这种方式使几乎任何HTML元素都可编辑。

设置超现实 (Setting Up Surreal)

添加您的网站 (Adding Your Site)

Start by creating an account. The first thing you'll see once you're in Surreal CMS is the sites page.

首先创建一个帐户 。 进入Surreal CMS后,您会看到的第一件事是网站页面。

Surreal CMS sites page

Select Add a New Site and you'll be taken to a form that asks for some information.

选择添加新站点 ,您将被带到询问一些信息的表单。

Adding a site in Surreal CMS

Enter your website's URL. Make sure you change the protocol to Amazon S3 and pick the correct region, otherwise Surreal won't be able to connect. You'll also need to enter your access key and secret key. If you don't have these handy, you can get them from the Security Credentials page in the AWS Management console. For added security, consider creating a separate access key just for this purpose.

输入您网站的URL。 确保将协议更改为Amazon S3并选择正确的区域,否则Surreal无法连接。 您还需要输入访问密钥和秘密密钥。 如果您没有这些方便的工具,则可以从AWS管理控制台的“ 安全凭证”页面获取它们。 为了提高安全性,请考虑为此创建一个单独的访问密钥 。

Once you're finished, hit Submit and your site will appear in Surreal.

完成后,单击“ 提交” ,您的网站将显示在“超现实”中。

启用页面 (Enabling Pages)

The next step is to enable your homepage for editing. Select your site and hit the Enable Pages button. A dialog will appear showing you the contents of your S3 bucket. Select index.html and then hit Done.

下一步是启用您的主页进行编辑。 选择您的站点,然后单击“ 启用页面”按钮。 将出现一个对话框,向您显示S3存储桶中的内容。 选择index.html ,然后点击完成

Congrats, you're ready to start editing!

恭喜,您已准备好开始编辑!

编辑页面 (Editing Pages)

Remember how you added that editable class to the homepage earlier? Well, you're about to see why. The glorious thing about Surreal is that you'll be editing your page inline, just like it appears in the wild. Select it from the list and you'll be taken straight to the Live Editor.

还记得您之前如何将editable类添加到主页吗? 好吧,您将要知道为什么。 关于Surreal的光荣之处在于,您将内联编辑页面,就像它在野外出现一样。 从列表中选择它,您将直接进入实时编辑器。

The Live Editor in Surreal CMS

Of course, you can make any changes you want in the editor—all the usual options are available. When you're done, go to Save > Publish and Surreal will save it to Amazon S3 for you!

当然,您可以在编辑器中进行所需的任何更改-所有常规选项均可用。 完成后,转到保存>发布 ,Surreal将为您将其保存到Amazon S3!

附加功能 (Extras)

Surreal also has a bunch of other great features that you'll find useful. To name a few:

超现实世界还具有许多其他有用的功能 ,您会发现它们很有用。 仅举几例:

  • Inline editing

    内联编辑
  • Responsive UI

    响应式用户界面
  • Photo gallery editor

    图片库编辑器
  • Google Analytics dashboard

    Google Analytics(分析)仪表板
  • Scheduled publishing

    预定发布
  • Change notifications

    变更通知
  • White-label support

    白标支持

While it isn't free, you can signup for a free trial and get a full month to play around with it. I may be biased, but it's definitely worth checking out ;)

它不是免费的,但您可以注册免费试用,并获得一个月的试用期 。 我可能有偏见,但是绝对值得一试;)

And there you have it. Now you know how to setup a website on Amazon S3 and edit it with minimal effort. If you have questions, leave them in the comments. If you enjoyed this tutorial, let me know!

那里有。 现在,您知道如何在Amazon S3上设置网站并进行最小的编辑。 如有疑问,请在评论中保留。 如果您喜欢本教程,请告诉我 !

翻译自: https://davidwalsh.name/hosting-website-amazon-s3

amazon s3

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_727210.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

linux文件服务器用途,文件服务器CPU篇 - 构建文件服务器:OS与CPU应用选择篇_服务器应用_Linux公社-Linux系统门户网站...

文件服务器CPU篇文件服务器的主要用途是存储&#xff0c;而不是处理能力&#xff0c;特别是家庭文件服务器而言&#xff0c;包括处理器在内部件都应该让位于硬盘、机箱和电源。文件服务器不需要最新的处理器&#xff0c;对于可能从来没必要将数据同时分发到多个客户机的文件服务…

必看,程序员应该访问的最佳网站

【公众号回复 “1024”&#xff0c;免费领取程序员赚钱实操经验】大家好&#xff0c;我是章鱼猫。今天给大家推荐的这个项目是「Best-websites-a-programmer-should-visit-zh」—— 程序员应该访问的最佳网站中文版&#xff0c;一些对程序员有用的网站。在学习 CS 的时候有一些…

查找微信公众号服务器,墨涩网 - 免插件实现微信公众号搜索连接wordpress网站文章——墨涩网...

微信公众号当前是每个用户都在使用的功能&#xff0c;而使用wordpress程序的站长会希望把自己的网站连接到微信公众号。连接后通过公众号访问网站的内容。目前网上有很多可以实现微信公众号和wordpress网站链接的插件很多&#xff0c;个人觉得醉的最好的应该是功能强大的水煮鱼…

php 网站语言切换,php 多语言切换

目录结构&#xff1a; // 文件内容&#xff1a; /include/language.php Java代码 ?php $languagesarray(); $languages[ zh-cn ][ name ] china ; $languages[ zh-cn ][ image ] flag1.jpg ; $languages[ en ][ name ] english目录结构&#xff1a;//文件内容&#xff1a;/inc…

突发:全球最大的同性交友网站挂了,修复长达四个小时的背后是一个悲伤的故事...

loonggg读完需要3分钟速读仅需 1 分钟今天下午&#xff0c;作为全球最大的同性交友网站&#xff1a;GitHub&#xff0c;突然挂了&#xff0c;一直在这两张图中间来回切换。再刷新一下&#xff0c;从 500 变成了小马&#xff0c;你还别说&#xff0c;我仔细看这个小马&#xff0…

2017年最受欢迎的10个编程挑战网站

来源&#xff1a;CSDN大数据 作者&#xff1a;Daniel Borowski 本文长度为1704字&#xff0c;建议阅读4分钟 如果你想不断地提高自己的编程技能&#xff0c;那么不断尝试去解决那些编程中的难题&#xff0c;这是一个非常不错的途径。本文为你列举了10个编程挑战网站&#xff0c…

透过日播放量超过6亿的《延禧攻略》,看2018视频网站格局

作者介绍徐麟目前就职于上海唯品会产品技术中心&#xff0c;哥大统计数据狗&#xff0c;从事数据挖掘&分析工作&#xff0c;喜欢用R&Python玩一些不一样的数据文章来源数据森麟如需转载&#xff0c;请联系原作者授权前言随着《延禧攻略》的播出&#xff0c;魏璎珞、富察…

看看黑客是如何攻破一个网站的?网友:原来...

点击上方[全栈开发者社区]→右上角[...]→[设为星标⭐]点击领取全栈资料&#xff1a;全栈资料通过本文你将了解黑客常用的入手思路和技术手法&#xff0c;适合热爱网络信息安全的新手朋友了解学习。本文将从最开始的信息收集开始讲述黑客是如何一步步的攻破你的网站和服务器的。…

有哪些网站,一旦知道,你就离不开了?

loonggg读完需要5分钟速读仅需 2 分钟大家好&#xff0c;我是你们的校长。感觉好久没有给大家分享工具类的好东西了&#xff0c;今天给大家分享几个好东西。作为程序员&#xff0c;一个技术人员&#xff0c;我从工作的角度和职场的角度给大家推荐几个非常不错的网站吧&#xff…

添加javascript_使用JavaScript将搜索添加到您的网站

添加javascriptStatic website generators like Gatsby and Jekyll are popular because they allow the creation of complex, templated pages that can be hosted anywhere. But the awesome simplicity of website generators is also limiting. Search is particularly ha…

不吸吮的网站建设者

我从不追求真棒 (I Never Pursue My Awesome Ideas) Im constantly struck with ideas for new web projects. Unfortunately, I rarely act on them because I have too little time and theyre too much of a hassle to see through. 我一直对新的Web项目的想法感到惊讶。 不…

GitHub Star 10K,让你的网站更炫酷的开源库

【公众号回复 “1024”&#xff0c;免费领取程序员赚钱实操经验】大家好&#xff0c;我是你们的章鱼猫。现在不少网站都支持了骨架屏&#xff0c;能够在网页数据加载前&#xff0c;展示固定的布局&#xff0c;能够减少用户在进入网页时感受到白屏的不适感。今天要给大家推荐一个…

bootstrap网站框架_启动框架:网站构建器,Bootstrap主题等

bootstrap网站框架One conclusion that Ive come to when evaluating my skills is that Im not a designer. Each time I redesign this blog, I identify a few sites I like and then meld them together. Of course that means I end up with UI components that dont lo…

牛逼啊,这两个程序员生财案例网站

loonggg读完需要4分钟速读仅需 2 分钟今天是日更生财技能的第二天。我决定每天写一篇生财感悟类的文章&#xff0c;带领大家每天「钱近」一小步。今天我读「生财日历」上 2 号的内容&#xff0c;上面讲的是一个变现超过 100 万美元的国外网课销售漏斗模型的案例。大致内容讲的就…

相亲网站比自己优秀的男人太多?单身程序员惊现神操作!

戳蓝字“CSDN云计算”关注我们哦&#xff01;话说&#xff0c;今年还有不到一个月就要过去了&#xff0c;作为一个单身狗的小编&#xff0c;看着大街上一个个成双成对的情侣&#xff0c;不由感到悲从心来&#xff0c;只能妄图从新闻中寻找一丝安慰。结果你别说&#xff0c;我最…

SEO核心技术纯白帽快速排名方法

我相信很多朋友都知道SEO快速排名&#xff0c;现在流行的快速排名都是众人皆知的黑帽SEO技术&#xff0c;但是却唯独不知道纯白帽也可以快速排名。但是我估计大家都看到过很多新站在短短数月内就上了首页&#xff0c;权重从0升到3&#xff0c;这难道是黑帽吗&#xff0c;不是的…

聊聊云计算:为什么构建网站时常会用到负载均衡

戳蓝字“CSDN云计算”关注我们哦&#xff01;作者&#xff1a;疯子程序员来源&#xff1a;https://blog.csdn.net/qq_40196321/article/details/85075746 负载均衡可以将客户端请求分摊到多个操作单元上进行处理硬件负载均衡负载均衡有很多种不同的实现方式&#xff0c;总的来说…

java比递归查询更快方法_使网站更小更快的5种方法

java比递归查询更快方法Confession: Id say once a week I genuinely wish I was a kid who spent his work day cutting grass and doing landscaping. Why? Because at the end of the day, they are able to say "the grass is cut, the job is complete." A…

干货 | NLP、知识图谱教程、书籍、网站、工具...(附资源链接)

来源&#xff1a;人工智能头条本文多资源&#xff0c;建议阅读收藏。本文整理了关于 NLP 与知识图谱的众多参考资源&#xff0c;涵盖内容与形式非常丰富。[ 导读 ]本文作者一年前整理了这份关于 NLP 与知识图谱的参考资源&#xff0c;涵盖内容与形式也是非常丰富&#xff0c;接…

透过日播放量超过6亿的《延禧攻略》,看2018视频网站格局(附代码)

来源&#xff1a;数据森麟本文约2000字&#xff0c;建议阅读6分钟。本文将对比各大视频网站2018年截止到8月18号的电视剧和综艺节目的播放情况&#xff0c;并对数据进行分析。[ 导读 ]随着《延禧攻略》的播出&#xff0c;魏璎珞、富察皇后等各位后宫小主的命运时刻牵动着各位观…