如何将Angular Universal项目部署到标准托管? [英] How to deploy Angular Universal project to standard hosting?

查看:147
本文介绍了如何将Angular Universal项目部署到标准托管?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的本地主机上有我的Angular Universal项目.因此,现在我想在安装了Node.js的标准虚拟主机上对其进行测试.

I have my Angular Universal project working on my localhost. So now I would like to test it on my standard web hosting with Node.js installed.

我已经跑步:

npm run build 

并收到带有 client server 子文件夹的 dist 文件夹.

and received dist folder with client and server subfolders.

我应该如何使用这些文件夹和文件在主机上运行项目?

How should I use these folders and files into them to run the project on the hosting?

谢谢.

推荐答案

所以我已经将Angular Universal项目部署到了​​主机上.

So I have deployed my Angular Universal project to my hosting.

我可以说托管的支持团队给了我很多帮助.我不知道是否可以自行部署此类项目.

I can say that the support team of my hosting gave me a lot of help. I don't know if is it possible to deploy such project on the own.

我的托管服务器具有Node.js支持.托管的支持团队向我提供了有关如何使用 terminal 在托管上安装Node.js的说明 Mac或Windows程序,例如 PuTTY .

My hosting has a Node.js support. Support team of the hosting gave me an instruction how to install Node.js on the hosting using terminal on Mac or programs for Windows like PuTTY.

然后,我完成了以下步骤:

Then I walked through the following steps:

  1. 在主机上为项目创建文件夹.
  2. dist 文件夹复制到创建的文件夹中.
  3. 在项目文件夹中安装NPM.在这一步,支持团队给了我一些帮助.因为您应该使用PATH来执行某些操作 NPM的正确安装和工作.
  4. 标准托管将 public_html 文件夹链接到您的域名.但是Angular Universal项目应该在单独的文件夹中. 所以我要求支持将我的域重定向到Angular 项目文件夹和正确的端口.
  5. 使用终端运行服务器:
  1. Create the folder for the project on the hosting.
  2. Copy the dist folder to created folder.
  3. Install NPM in the project folder. At this step support team gave me some help. Because you should do something with PATH to proper install and work of NPM.
  4. Standard hosting links the public_html folder to your domain name. But Angular Universal project should be in a separate folder. So I have asked the support to redirect my domain to the Angular project folder and proper port.
  5. Run server using terminal:

节点dist/server/server.js

node dist/server/server.js

毕竟,我可以看到我的项目在我的域名上运行良好.

After all I can see my project working good on my domain name.

添加.我还尝试了以下方法:将我的项目文件夹(没有 node_modules 文件夹)复制到托管服务器,然后运行

Addition. Also I tried the following way: copied my project folder (without node_modules folder) to the hosting and then run

npm安装

npm install

npm运行构建

您还可以通过以下命令在主机上创建 dist 文件夹.

You can create the dist folder on the hosting also by these commands.

添加..假设您在主机上配置了Node.js服务器.另外,您还应确保项目已准备好进行部署.这是代码需要对此进行预修的链接: https://github .com/angular/angular-cli/wiki/stories-universal-rendering

Addition. Assume that you config your Node.js server on your hosting. Also you should make shure that your project ready to be deployed. Here is a link what code needs to prepair this: https://github.com/angular/angular-cli/wiki/stories-universal-rendering

您还需要在主机上复制您的 client/ server/文件夹,以及 server.js 软件包. json 文件. 然后,您可以通过以下方式运行应用程序

You also need to copy on your hosting your client/ and server/ folders and also server.js and package.json files. Then you can run your application by

node server.js

node server.js

这篇关于如何将Angular Universal项目部署到标准托管?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆