【问题标题】:How to deploy meteorjs project to digital ocean?如何将meteorjs项目部署到数字海洋?
【发布时间】:2013-05-19 23:02:14
【问题描述】:

如何将meteorJS项目部署到Digital Ocean VPS? CentOS x64 - 对它有好处吗?还是我需要设置其他东西?

【问题讨论】:

  • 只需确保在部署中使用节点 0.8.2x,因为 0.10.x 存在 centos 问题和 sockjs 内存泄漏问题

标签: node.js deployment meteor production digital-ocean


【解决方案1】:

这有点难,如果您是 Meteor 和 Node.js 的新手,那么掌握起来就太难了。

  1. 您首先必须在您的 Digital Ocean VPS 上设置 Node.js:

    How to install Node.js on Ubuntu
    https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
    
  2. 然后你必须打包你的 Meteor 应用程序: http://docs.meteor.com/#deploying

    meteor bundle myapp.tgz
    
  3. 然后你要么在 VPS 上安装 MongoDB,要么注册 MongoHQ

  4. 然后你必须启动应用程序:

    PORT=3000 MONGO_URL=mongodb://localhost:27017/myapp node bundle/main.js
    

【讨论】:

  • 安装和运行流星的说明位于doc.meteor.com -- quickstart,并且可以在支持操作系统的 Digital Ocean vps 上正常工作。
【解决方案2】:

meteor.sh 脚本将帮助您提供设置和部署命令。无论如何,设置命令对我来说是错误的,所以我安装了所有东西:

sudo apt-get install software-properties-common
sudo apt-get install python-software-properties python g++ make
add-apt-repository ppa:chris-lea/node.js
sudo apt-get update

sudo apt-get install nodejs
sudo apt-get install -y build-essential  
apt-get install mongodb
npm install -g forever

然后使用meteor.sh部署 您必须检查 meteor.sh 文件并找到它修补 server.js 文件的行,因为该文件可能会随着时间而改变,您必须确保修补程序针对正确的行。

如果应用仍然损坏,请设置以下变量:

export APP_NAME=meteorapp
export ROOT_URL=http://yourdomain.com
export APP_DIR=/var/www/meteorapp
export MONGO_URL=mongodb://localhost:27017/meteorapp

这或多或少对我有用 UBUNTU 32bit V12

【讨论】:

    【解决方案3】:

    安装服务器软件

    $ sudo apt-get install software-properties-common
    $ sudo apt-get install python-software-properties python g++ make
    $ sudo add-apt-repository ppa:chris-lea/node.js
    $ sudo apt-get update
    
    $ sudo apt-get install nodejs
    $ sudo apt-get install -y build-essential  
    $ sudo apt-get install mongodb
    $ npm install -g forever
    

    生成捆绑包

    $ meteor bundle myapp.tgz
    

    在服务器中复制并解压缩此文件,为您的应用创建一个 bundle 文件夹。

    测试您的应用:

    $ export ROOT_URL=http://mydomain.com
    $ PORT=3000 MONGO_URL=mongodb://localhost:27017/myapp node bundle/main.js
    

    调整

    永远使用

    https://github.com/nodejitsu/forever

    永远测试:

    $ PORT=3000 MONGO_URL=mongodb://localhost:27017/myapp forever start bundle/main.js
    
    $ ps aux | grep node
    
    $ forever list
    
    $ forever stop bundle/main.js 
    

    在服务器初始化时运行应用程序

    $ sudo vi /etc/rc.local
    
    ...
    
    # Launch Meteor app
    export ROOT_URL=http://mydomain.com:3000
    PORT=3000 MONGO_URL=mongodb://localhost:27017/myapp /usr/bin/forever start /home/user/bundle/main.js
    
    exit 0
    

    在脚本中使用绝对路径,根据您的服务器/应用配置更改上述路径。

    【讨论】:

      猜你喜欢
      • 2017-12-12
      • 2015-03-14
      • 2022-01-10
      • 1970-01-01
      • 1970-01-01
      • 2016-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多