Struct
Struct

Reputation: 970

Deploying meteor app to a webserver

Does anyone know a step by step guide to deploy the own meteor app from windows to a webspace (not xxx.meteor.com).

I've found some tools like meteor.sh, but I'm a beginner and it's difficult without a guidance and without linux (needed to execute sh-files for example)

Upvotes: 0

Views: 2422

Answers (2)

Kuba Wyrobek
Kuba Wyrobek

Reputation: 5273

I recommend Meteoric. Note, that you need to run meteoric from your development machine.

Script is self explanatory and works perfect for me.

Upvotes: 2

Tarang
Tarang

Reputation: 75965

Make your project locally

Build your project locally, you could test it using meteor run or even meteor deploy xxx.meteor.com to see if its working

Bundle your app

Use meteor bundle deploy.tar.gz to make a file called deploy.tar.gz in your meteor directory containing your project

Upload your file to your server

This depends more on how your server is/what your platform is but you can use a tool to upload it for you (e.g Transmit on mac)

Install node.js & fibers on your platform if you don't have it already

This depends alot on your server platform. Have a look at http://nodejs.org/ for more detailed instructions

Extract your bundle

If on a *nix platform you could do the below in the directory where you uploaded your bundle (explanation):

tar -xzvf bundle.tar.gz

Enter the directory and install fibers

Fibers is needed for any meteor project, it helps use synchronous style code on server side javascript:

cd bundle/programs/server/node_modules
rm -r fibers
npm install [email protected]

The first line enters the directory in your bundle where fibers is installed, the second removes it, and the third reinstalls it.

Get MongoDB on another server or use a third party service like mongohq

Meteor production deployments need another mongodb. You can either install it on another server or use a third party server. It's not recommended to install it on the same server you install meteor on.

Finally check if your project is runnable

cd ../../../
node MONGO_URL=mongodb://dbuser:dbpassword@dbhost:dbport/meteor ROOT_URL=http://yourwebsite.com app.js

The first line gets you back to the bundle directory and the second runs node.js on your project with the parameters that let you connect to your mongodb database.

Install something to let it run in the background

It depends on which one you want to use, foreverjs is quite easy to use

npm install forever -g

If you get an error problem try using sudo before the npm (which lets you run as a super user).

Then you can run forever:

forever start MONGO_URL=mongodb://dbuser:dbpassword@dbhost:dbport/meteor ROOT_URL=http://yourwebsite.com app.js

And its done!

Extra notes

While its not that easy to get started from scratch this should help you get started. You still need to secure your mongodb server up if you've used your own servers.

The meteor.sh script does pretty much the same as above but very quickly if you learn to use that instead it might be faster to deploy updates

You might not have wget or a couple of commands that you might need that come up and give you Unknown command errors. Have a go at running yum or apt-get and see which one of the two you might have. You can then install the required package using one of these installer tools, i.e with yum install wget

I hope this helps you, its not that easy to deploy to a server on the first shot as a couple of things might be missing (files/packages/dependencies), you might run into other problems with permissions & stuff, but you could always ask on serverfault or here on stackoverflow on what you run into.

Upvotes: 5

Related Questions