博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
next.js部署_立即部署Next.js应用程序
阅读量:2505 次
发布时间:2019-05-11

本文共 3015 字,大约阅读时间需要 10 分钟。

next.js部署

Zeit is now called , and this tutorial might be outdated

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

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 platform created by , 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应用程序最简单的方法之一是通过创建的平台,该平台创建了开源项目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 functions invocations per day, 1000 builds per month, 100GB of bandwidth per month, and one location. The helps get an idea of the costs if you need more.

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

安装 (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 before continuing, then add your email to the CLI client.

如果尚未注册, 在继续之前在上创建一个帐户,然后将电子邮件添加到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子域足以满足我们的测试目的。

翻译自:

next.js部署

转载地址:http://dlqgb.baihongyu.com/

你可能感兴趣的文章
设计模式
查看>>
5.0以上机器XPOSED框架安装流程
查看>>
静态方法与非静态方法
查看>>
[转]iOS进阶路线以及进阶书籍
查看>>
期货监管机构,国际著名。
查看>>
vim编程技巧
查看>>
Activator.CreateInstance 方法 (Type) 的用法
查看>>
我的将军啊
查看>>
openstack mariadb 容器无法启动问题解决方法
查看>>
实例的初始化过程: new 对象
查看>>
10.02 一个简单的串口的初始化程序
查看>>
Ant学习笔记
查看>>
vc++ 在程序中运行另一个程序的方法
查看>>
Python面向对象编程及内置方法
查看>>
HTML5 Web Storage
查看>>
Poco之ftp目录切换与创建
查看>>
C#泛型参数多线程与复杂参数多线程
查看>>
java读取文件内容
查看>>
供应链管理
查看>>
装箱和拆箱
查看>>