top of page

Guide: How to Deploy Meteor / Telescope on Centos

  • Writer: Qasim Zee
    Qasim Zee
  • Dec 30, 2014
  • 4 min read

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:

Shell

yum update yum groupinstall "Development Tools"

1

2

yum

update

yum

groupinstall

"Development Tools"

 Install Node.js

Shell

wget http://nodejs.org/dist/v0.10.35/node-v0.10.35.tar.gz tar xvfz node-v0.10.35.tar.gz cd node-v0.10.35 ./configure make sudo make install

1

2

3

4

5

6

wget

http

:

/

/

nodejs

.org

/

dist

/

v0

.

10.35

/

node

-

v0

.

10.35.tar.gz

tar

xvfz

node

-

v0

.

10.35.tar.gz

cd

node

-

v0

.

10.35

.

/

configure

make

sudo

make

install

Install MongoDB

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

For 64 bit:

Shell

[mongodb] name=MongoDB Repository baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/ gpgcheck=0 enabled=1

1

2

3

4

5

[

mongodb

]

name

=

MongoDB

Repository

baseurl

=

http

:

/

/

downloads

-

distro

.mongodb

.org

/

repo

/

redhat

/

os

/

x86_64

/

gpgcheck

=

0

enabled

=

1

For 32 bit:

Shell

[mongodb] name=MongoDB Repository baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686/ gpgcheck=0 enabled=1

1

2

3

4

5

[

mongodb

]

name

=

MongoDB

Repository

baseurl

=

http

:

/

/

downloads

-

distro

.mongodb

.org

/

repo

/

redhat

/

os

/

i686

/

gpgcheck

=

0

enabled

=

1

And:

yum install mongo-10gen mongo-10gen-server

1

yum

install

mongo

-

10gen

mongo

-

10gen

-

server

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:

Shell

meteor build --directory yourapp_prod

1

meteor

build

--

directory

yourapp_prod

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:

Shell

cd yourapp_prod/bundle/programs/server export PORT=8080 export MONGO_URL=mongodb://localhost:27017/yourapp_db export ROOT_URL=http://yourapp_domain/ npm install cd ../../../ node bundle/main.js

1

2

3

4

5

6

7

cd

yourapp_prod

/

bundle

/

programs

/

server

export

PORT

=

8080

export

MONGO_URL

=

mongodb

:

/

/

localhost

:

27017

/

yourapp_db

export

ROOT_URL

=

http

:

/

/

yourapp_domain

/

npm

install

cd

.

.

/

.

.

/

.

.

/

node

bundle

/

main

.js

It might give the following error that I am not sure about: /home/yourapp_prod/bundle/programs/server/node_modules/fibers/future.js:173throw(ex);^Error: /home/yourapp_prod/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/build/Release/bcrypt_lib.node: invalid ELF headerat 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:

Shell

cd /home/yourapp_prod/bundle/programs/server npm install bcrypt cp -r /home/yourapp_prod/bundle/programs/server/node_modules/bcrypt /home/yourapp_prod/bundle/programs/server/npm/npm-bcrypt/node_modules/

1

2

3

cd

/

home

/

yourapp_prod

/

bundle

/

programs

/

server

npm

install

bcrypt

cp

-

r

/

home

/

yourapp_prod

/

bundle

/

programs

/

server

/

node_modules

/

bcrypt

/

home

/

yourapp_prod

/

bundle

/

programs

/

server

/

npm

/

npm

-

bcrypt

/

node_modules

/

Let’s try to run the app again:

cd /home/yourapp_prod node bundle/main.js

1

2

cd

/

home

/

yourapp_prod

node

bundle

/

main

.

js

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.

npm -g install forever forever start yourapp_prod/bundle/main.js

1

2

npm

-

g

install

forever

forever

start

yourapp_prod

/

bundle

/

main

.

js

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:

XHTML

<VirtualHost *:80> ServerName yourapp_domain ProxyRequests off <Proxy *> Order deny,allow Allow from all </Proxy> <Location /> ProxyPass http://localhost:8080/ ProxyPassReverse http://localhost:8080/ </Location> </VirtualHost>

1

2

3

4

5

6

7

8

9

10

11

12

<VirtualHost

*

:

80

>

  ServerName yourapp_domain

  ProxyRequests off

<Proxy

*

>

    Order deny,allow

    Allow from all

</Proxy>

<Location

/>

    ProxyPass http://localhost:8080/

    ProxyPassReverse http://localhost:8080/

</Location>

</VirtualHost>

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

Recent Posts

See All
Centos, Varnish, NGINX, Drupal

As an experiment this week I decided to change the web server of a site to NGINX, the existing web server was Apache.

 
 
 

Comentarii


bottom of page