简体   繁体   English

在Google Cloud Platform上部署MEAN.JS

[英]Deploy MEAN.JS on Google Cloud Platform

I tried to deploy MEAN.JS on Google Cloud Platform (also the KeystoneJS CMS), but it doesn't work. 我尝试在Google Cloud Platform(也包括KeystoneJS CMS)上部署MEAN.JS,但是它不起作用。 I use the command-line tool online. 我在线使用命令行工具。

In the order, i installed Node.js, MongoDB, bower and grunt, then I try to deploy MEAN.JS : 按照顺序,我安装了Node.js,MongoDB,bower和grunt,然后尝试部署MEAN.JS:

  • Install Node.js : sudo apt-get install curl curl -sL https://deb.nodesource.com/setup | sudo bash - sudo apt-get install -y nodejs nodejs-legacy 安装Node.js: sudo apt-get install curl curl -sL https://deb.nodesource.com/setup | sudo bash - sudo apt-get install -y nodejs nodejs-legacy sudo apt-get install curl curl -sL https://deb.nodesource.com/setup | sudo bash - sudo apt-get install -y nodejs nodejs-legacy

  • Install MongoDB : sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 echo 'deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list sudo apt-get update sudo apt-get install -y mongodb-org 安装MongoDB: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 echo 'deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list sudo apt-get update sudo apt-get install -y mongodb-org sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 echo 'deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list sudo apt-get update sudo apt-get install -y mongodb-org

  • Install bower et Grunt : sudo npm install -g bower sudo npm install -g grunt-cli 安装bower et Grunt: sudo npm install -g bower sudo npm install -g grunt-cli

  • Install MEAN.js : sudo npm install -g generator-meanjs mkdir mean cd mean yo meanjs grunt 安装MEAN.js: sudo npm install -g generator-meanjs mkdir mean cd mean yo meanjs grunt

Here is the result on the command-line board : 这是命令行板上的结果:

Running "jshint:all" (jshint) task 53 files lint free. Running "csslint:all" (csslint) task 2 files lint free. Running "concurrent:default" (concurrent) task Running "watch" task Running "nodemon:dev" (nodemon) task Waiting... [nodemon] v1.2.1 [nodemon] to restart at any time, enter rs [nodemon] watching: app/views/ / . gruntfile.js server.js config/ / .js app/* /*.js [nodemon] starting node --debug server.js debugger listening on port 5858 NODE_ENV is not defined! Using default development environment js-bson: Failed to load c++ bson extension, using pure JS version Failed to load c++ bson extension, using pure JS version MEAN.JS application started on port 3000

I can define the NODE_ENV variable (test, development, all...) but it's the same problem. 我可以定义NODE_ENV变量(测试,开发等),但这是相同的问题。


The problem is : 问题是 :
It should work but whan i try to access to my IP:port (in this case 146.148.113.68:3000) : "This webpage is not available". 它应该可以工作,但是如果我尝试访问我的IP:端口(在本例中为146.148.113.68:3000):“此网页不可用”。
Is it a problem with the VM, the packages, MEAN.JS ? VM,软件包MEAN.JS是否有问题? I have the same problem with the KeystoneJS CMS. 我在KeystoneJS CMS中有相同的问题。

Thanks ! 谢谢 !

Are you sure ports to your machine are open for access? 您确定机器的端口已打开以供访问吗? When you deploy an app on Compute Engine, you have to edit network settings to allow custom ports. 在Compute Engine上部署应用程序时,必须编辑网络设置以允许自定义端口。 There's easy checkmark options for allowing HTTP and HTTPs traffic, but for custom ports, you will have to add port in settings. 有简单的复选标记选项可用于允许HTTP和HTTP通信,但是对于自定义端口,则必须在设置中添加端口。

This documentation might be helpful but you can always find these things in the Cloud Console. 该文档可能会有所帮助,但您始终可以在Cloud Console中找到这些内容。

Also, now Google Cloud Launcher also supports MEAN stack deployment with both MEAN.io and MEAN.js flavors which simplifies the whole process. 此外,现在Google Cloud Launcher还支持MEAN.io和MEAN.js两种版本的MEAN堆栈部署,从而简化了整个过程。

Everything looks fine Only thing to change is the firewall settings which is blocking your web application ,there is no problem with VM or KeystoneJS CMS. 一切看起来都很好,唯一需要更改的是阻止您的Web应用程序的防火墙设置,VM或KeystoneJS CMS没有问题。 You Need to just change the firewall settings for incoming and Outing Traffic: 您只需要更改传入和传出流量的防火墙设置即可:

防火墙设置

You need to specify the ip and port number , i have given access to all ports temporarily for testing purpose. 您需要指定ip和端口号,出于测试目的,我已临时访问所有端口。

在此处输入图片说明

Try other services to host your MEANJS Web Application. 尝试其他服务来托管您的MEANJS Web应用程序。 Heroku : https://www.heroku.com/ Nodejitsu : https://www.nodejitsu.com/ Heroku: https: //www.heroku.com/ Nodejitsu: https ://www.nodejitsu.com/

If it works in these platoforms,then the problem is not with your cloud. 如果它可以在这些平台上运行,那么问题就不在于您的云。

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

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