Saturday 10 October 2015

Hosting your Meteor App

This is the toughest part, deploying meteor application, all the tutorials i tried are confusing, i myself faced this problem
so decided to write a tutorial on how i was able to successfully host my meteor app

USE MUPX

i hosted my meteor app on dedicated linux server with 1TB hard drive and 16gb ram and ubuntu server os

We are using linux machine, lubuntu was our os , this might not work on windows, we were using linux machine for development



install mupx on your local machine
related link
https://github.com/arunoda/meteor-up/tree/mupx#

npm install -g mupx

node and npm should be installed on your local machine

got to your project directory

cd /projectdirectory

mupx init

this will create mup.json and settings.json file in your project folder

now most important thing is to configure your mup.json file

{
// Server authentication info
"servers": [
    {
"host": "64.23.434.2",
"username": "root",
"password": "rootpassword",
// or pem file (ssh based authentication)
      // WARNING: Keys protected by a passphrase are not supported
      //"pem": "~/.ssh/id_rsa",
      // Also, for non-standard ssh port use this
"sshOptions": { "port" : 7576 },
// server specific environment variables
"env": {}
    }
  ],

// Install MongoDB on the server. Does not destroy the local MongoDB on future setups
"setupMongo": true,

// Application name (no spaces).
"appName": "yourappname",

// Location of app (local directory). This can reference '~' as the users home directory.
  // i.e., "app": "~/Meteor/my-app",
  // This is the same as the line below.
"app": "/home/websol/myproject", <<--- this path is of your local machine where the project files are

// Configure environment
  // ROOT_URL must be set to your correct domain (https or http)
"env": {
"PORT": 80,
"ROOT_URL": "http://yourdomain.com"
//"MONGO_URL": "mongodb://127.0.0.1:27017/meteor",

},

// Meteor Up checks if the app comes online just after the deployment.
  // Before mup checks that, it will wait for the number of seconds configured below.
"deployCheckWaitTime": 120,

// show a progress bar while uploading.
  // Make it false when you deploy using a CI box.
"enableUploadProgressBar": true
}


this is the example of mup.json file of lovenmarrymails


"servers": [
    {
"host": "64.23.232.3", <-- your server ip
"username": "root",
"password": "rootpassword",
// or pem file (ssh based authentication)
      // WARNING: Keys protected by a passphrase are not supported
      //"pem": "~/.ssh/id_rsa",
      // Also, for non-standard ssh port use this
"sshOptions": { "port" : 7576 },
// server specific environment variables
"env": {}
    }

add your server connection details here
host , username, password

if there is ssh root conntion details then it will be ok
if you have diffrent port for sshconnection then mention it

"sshOptions": { "port" : 7576 }

or by default it will take port 22


no mongodb installed on server

// Install MongoDB on the server. Does not destroy the local MongoDB on future setups
"setupMongo": true,

this will install it on docker

better is to choose this option only

if you set  "setupMongo": false,

then you have to specify path in env

but it might give port accessing error so avoid this

/ This is the same as the line below.
"app": "/home/websol/projectfiles",

here you have to give path of your local machine project directory

"env": {
"PORT": 80,
"ROOT_URL": "http://yourdomain.com"
//"MONGO_URL": "mongodb://127.0.0.1:27017/meteor",

},

mention the port and root_url of your project

now your mup.json is configured now

mupx reset

this command will set environment install docker, install mongodb on your server

in this command error will be shown if there is any

like connection problem or installation problem etc.

else your config is right


mupx deploy

this command will upload the bundle on your server

and start your app

now go to web browser and run your root_url you have mentioned

and your meteor app is running

this will bundle your app on server  at /opt/yourapp/current/
location