简体   繁体   English

在没有节点的服务器上将node.js应用程序作为静态文件运行

[英]Run node.js application as static files on server without node

We want to put up a node application on a Linux CentOS 6 server where there is no possibility of installing Node. 我们希望在无法安装Node的Linux CentOS 6服务器上建立一个节点应用程序。

So if I've understood correctly, the site can't be run with an Express server that serves the files if node isn't installed on the server. 因此,如果我没有正确理解,则该站点不能与提供文件的Express服务器一起运行,如果该服务器上未安装node的话。 My question is, can I run the site if it is compiled and bundled into static files? 我的问题是,如果网站已编译并捆绑到静态文件中,我可以运行该网站吗?

In app.js , there is a line where the express method "listen" opens a port for the site to run on. app.js ,有一行在其中express方法“ listen”打开一个端口以供网站运行。 I have seen that there is a "static" alternative: express.static(root, [options]) 我已经看到有一个“静态”替代方法: express.static(root, [options])

Would it work putting up a node site and run it with that static option, without node being installed on the server? 无需在服务器上安装节点,是否可以建立一个节点站点并使用该静态选项运行它?

I know this isn't exactly the answer you are looking for, but I would recommend that instead of trying to run node.js as an static file you Dockerize your Node.js application. 我知道这并不是您要找的答案,但我建议您对Dockerize Node.js应用程序进行操作,而不是尝试将node.js作为静态文件运行。 You should be able to then run the Docker application on CentOS. 然后,您应该能够在CentOS上运行Docker应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM