如何将MeteorJS项目部署到Digital Ocean?

9
如何将 MeteorJS 项目部署到 Digital Ocean VPS?CentOS x64 - 适合吗?还是我需要设置其他东西?

请确保在部署时使用Node 0.8.2x,因为0.10.x在CentOS上存在问题,并且会导致SockJS的内存泄漏。 - Tarang
3个回答

5

这可能有点困难,如果你是 Meteor 和 Node.js 的新手,那么理解起来可能会太过于复杂。

  1. You will first have to setup Node.js on your Digital Ocean VPS:

    How to install Node.js on Ubuntu
    https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
    
  2. Then you wil have to package your Meteor app: http://docs.meteor.com/#deploying

    meteor bundle myapp.tgz
    
  3. Then you would either install MongoDB on the VPS or sign up for MongoHQ

  4. Then you have to start the app:

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

安装和运行Meteor的说明在doc.meteor.com -- quickstart,并且在支持的操作系统上,可以在Digital Ocean VPS上正常工作。 - user728291

4

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 deploy命令。您需要检查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

这在我使用32位UBUNTU V12时,更或多或少地起作用了。

0

安装服务器软件

$ 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

生成 Bundle

$ meteor bundle myapp.tgz

将此文件复制并解压缩到服务器上,创建一个名为bundle的文件夹,并将其与您的应用程序一起使用。

测试您的应用程序:

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

调优

使用forever

https://github.com/nodejitsu/forever

使用 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

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接