Guide: How to Deploy Meteor / Telescope on Centos

Feel free to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

Deploying meteor or telescope can be tricky sometimes especially when it comes to centos support. Here are the steps I am following to deploy my meteor app.

Development Environment:

  • OSX

Production Environment:

  • Linode 1GB
  • Centos 7
  • Apache

Software Stack on production:

  • Mongo DB
  • Node.js 0.10.35
  • NodeJS “Forever” module to start application in the background

I am not using NGINX as most of the people suggest as I already have a lot of applications running on Apache.

Just make sure that all the development libraries are available:

 Install Node.js

Install MongoDB

Create a /etc/yum.repos.d/mongodb.repo file to hold the following configuration information for the MongoDB repository:

For 64 bit:

For 32 bit:

And:

The server setup is done. Please don’t need that you don’t need to install meteor or telescope in your production environment.

Package your app

On your local (development) machine, go to your meteor / telescope app directory and enter the following command:

It will build a new directory in your app directory named “yourapp_prod” It contains the bundle of your app. Compress yourapp_prod and upload to your servers home directory.

Push app to server

Make sure the port is free. If it is not free, you can use 3000 instead of 8080. Uncompress the file in your server’s /home directory and try start your app in the following series of commands:

It might give the following error that I am not sure about:
/home/yourapp_prod/bundle/programs/server/node_modules/fibers/future.js:173
throw(ex);
^
Error: /home/yourapp_prod/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/build/Release/bcrypt_lib.node: invalid ELF header
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at bindings (/home/yourapp_prod/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/node_modules/bindings/bindings.js:74:15)
at Object.<anonymous> (/home/yourapp_prod/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/bcrypt.js:1:97)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)

But there is a fix for that:

Let’s try to run the app again:

It should work ok now. Try to enter http://yourapp_domain:8080/ in the browser and it should work.

But the problem is if you quit your terminal, your app will stop working. You can install node “forever” module to run your app in the background.

But you don’t want to make it work with http://yourapp_domain:8080/, you want to make it work with http://yourapp_domain/

You can configure a reverse proxy in your apache configuration. In case of Centos 7, you need to create some file like /etc/httpd/conf.d/yourapp_domain.conf. The contents of the file will be something like:

In my case, the app is running at port 8080, you can change the port number accordingly.

Restart apache now and your are DONE.

If you want more support or want to hire me, feel free to write in comments on write me directly at ping@qasimzeeshan.com

Feel free to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone
  • http://iamtechnical.com/ Azhar Ahmed

    Nice work!

    • http://qasimzeeshan.com Qasim Zeeshan

      Thanks a lot 🙂

  • Bogdan Kulbida

    Thanks a lot. especially for the fixing issue with fibers!

    • http://qasimzeeshan.com Qasim Zeeshan

      Sure, my pleasure

  • Nikita Lavrenko

    Thanks, Thanks, Thanks!

    • http://qasimzeeshan.com Qasim Zeeshan

      Sure, most welcome 🙂

  • Steve Enders

    Should this work with CentOS 6, as well?

    • http://qasimzeeshan.com Qasim Zeeshan

      Hi

      Haven’t tested it but please feel free to share your feedback

      • Steve Enders

        Tested it this afternoon with our demo app. Worked like a charm. It’s the first thing that has successfully led to a deployment on my CentOS 6/Apache setup. Now to get to work building the “big one” we have planned.

        • http://qasimzeeshan.com Qasim Zeeshan

          Great

          • Steve Enders

            What have you done for version and update handling?

          • http://qasimzeeshan.com Qasim Zeeshan

            Nothing:)

            Just do it manually

          • Steve Enders

            Kinda what I figured, but wanted to ask.

            Have you successfully run multiple apps from the same server simultaneously using this method?

          • http://qasimzeeshan.com Qasim Zeeshan

            Yes, just run on different ports.

          • Steve Enders

            Thanks for confirming!

  • http://www.chiefdreamer.com/ David Giorgi

    Thanks Qasim!
    Greetings from Annecy, France

  • Sreejith S

    I got an error while deploy the meteor webapp in server as production mode. I have node(0.10.41), mongodb(v2.6.11) and npm(3.7.3) in my centos 6 server. while running it, I am getting below errors :

    ‘Failed to load bson c++ extension, using pure js version ,

    …/cfs_gridfs/npm/node_module/bson/build/release/bson.node invalid ELF header’.

    • http://qasimzeeshan.com Qasim Zeeshan

      Try to install make tools?

  • austin

    Thank you Qasim for the detailed document, i was strugling to do this from 2 days,
    it worked like charm. 🙂

    • austin

      I was trying to connect to my meteor project through https using self signed ssl key and certificate, but when i give my app’s URL in browser it will redirect into Apache Test page.

      In the ssl_error-log i’m getting Cannot serve directory /var/www/myapp/bundle/public/ : No matching Directory Index (index.html) found.

      The same directory is working fine in http connection (I don’t have index file in meteor page)

      • http://qasimzeeshan.com Qasim Zeeshan

        Hi Austin

        I am happy it helped you. Regarding ssl, I am not sure yet but will take a look whenever I get some time