next.js部署_立即部署Next.js应用程序

next.js部署

Zeit is now called Vercel, and this tutorial might be outdated

Zeit现在称为Vercel ,并且本教程可能已过时

How do we deploy a Next.js app to a real web server, so other people can access it?

我们如何将Next.js应用程序部署到真实的Web服务器上,以便其他人可以访问它?

One of the most simple ways to deploy a Next application is through the Now platform created by Zeit, the same company that created the Open Source project Next.js. You can use Now to deploy Node.js apps, Static Websites, and much more.

部署Next应用程序最简单的方法之一是通过Zeit创建的Now平台,该平台创建了开源项目Next.js。 您可以使用Now来部署Node.js应用程序,静态网站等。

Now makes the deployment and distribution step of an app very, very simple and fast, and in addition to Node.js apps, they also support deploying Go, PHP, Python and other languages.

现在使应用程序的部署和分发步骤变得非常,非常简单和快速,并且除了Node.js应用程序外,它们还支持部署Go,PHP,Python和其他语言。

You can think of it as the “cloud”, as you don’t really know where your app will be deployed, but you know that you will have a URL where you can reach it.

您可以将其视为“云”,因为您并不真正知道应用程序的部署位置,但是您知道将拥有一个可以访问它的URL。

Now is free to start using, with generous free plan that currently includes 100GB of hosting, 1000 serverless functions invocations per day, 1000 builds per month, 100GB of bandwidth per month, and one CDN location. The pricing page helps get an idea of the costs if you need more.

现在可以免费开始使用了免费的免费计划,该计划目前包括100GB托管,每天1000次无服务器功能调用,每月1000次构建,每月100GB带宽以及一个CDN位置。 定价页面可帮助您了解所需的成本。

安装 (Installation)

The best way to start using Now is by using the official Now CLI:

开始使用Now的最佳方法是使用官方的Now CLI:

npm install -g now

Once the command is available, run

命令可用后,运行

now login

and the app will ask you for your email.

然后该应用会询问您的电子邮件。

If you haven’t registered already, create an account on https://zeit.co/signup before continuing, then add your email to the CLI client.

如果尚未注册, 在继续之前在https://zeit.co/signup上创建一个帐户,然后将电子邮件添加到CLI客户端。

Once this is done, from the Next.js project root folder run

完成此操作后,从Next.js项目根文件夹运行

now

and the app will be instantly deployed to the Now cloud, and you’ll be given the unique app URL:

并且该应用将立即部署到Now云中,并且会为您提供唯一的应用URL:

Once you run the now program, the app is deployed to a random URL under the now.sh domain.

运行now程序后,该应用程序将部署到now.sh域下的随机URL。

We can see 3 different URLs in the output given in the image:

我们在图像中给出的输出中可以看到3个不同的URL:

Why so many?

为什么那么多?

The first is the URL identifying the deploy. Every time we deploy the app, this URL will change.

第一个是标识部署的URL。 每次我们部署应用程序时,此URL都会更改。

You can test immediately by changing something in the project code, and running now again:

您可以通过在项目中的代码改变的东西,并立即运行测试now再次:

The other 2 URLs will not change. The first is a random one, the second is your project name (which defaults to the current project folder, your account name and then now.sh).

其他2个URL不会更改。 第一个是随机的,第二个是您的项目名称(默认为当前项目文件夹,您的帐户名,然后是now.sh )。

If you visit the URL, you will see the app deployed to production.

如果您访问该URL,您将看到该应用程序已部署到生产环境。

You can configure Now to serve the site to your own custom domain or subdomain, but I will not dive into that right now.

您可以配置“现在”以将网站提供给您自己的自定义域或子域,但是我现在不会对此进行介绍。

The now.sh subdomain is enough for our testing purposes.

now.sh子域足以满足我们的测试目的。

翻译自: https://flaviocopes.com/nextjs-deploy-on-now/

next.js部署

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值