Pergunta

I am having a problem Installing Meteor on Webfaction and setting up sites and apps , as i look through there is no detailed instructions how to achieve this , and Webfaction support is not providing detailed support as well .

First issue :

How to install Meteor on Webfaction as shared hosting without root permission ?

2nd issue :

How to setup the app and configure the port and the run the app server in the background .

3rd issue : Do i need to setup MongoDB , As Meteor has it's own version of MongoDB ?

Foi útil?

Solução

After some struggling I managed to successfully deploy a Meteor 0.6.6.3 application on Webfaction, here's the process.

Basically you need to use Demteorizer to convert the Meteor app into a Node.js app for it to run, you do need to setup a MongoDB instance either on your webfaction server or a DB hosting service like MongoHQ / MongoLab, Meteor's own MongoDB cannot be used in this case.

Install these things on the Webfaction server:

  1. Node.js and npm
  2. Forever (using npm)
  3. MongoDB

To deploy the app:

  1. Add two custome applications in the Webfaction management console, one for MongoDB and one for your app, node down the two ports that the apps are listening on. Let's call them MONGO_PORT and APP_PORT. You also need to have a domain and attach the custome app to that domain's website.

  2. Install Demeteorizer locally and follow its instructions to convert your application into a Node.js one, and then upload the converted app onto the webfaction server. You can either use ftp or a setup a git repository to make the upload process easier.

  3. Start up your MongoDB instance on Webfaction, run it in daemon mode with this command on your ssh shell:

    mongod --fork --logpath ~/tmp/mongodb.log --dbpath ~/.data/db --port [MONGO_PORT]
    
  4. Setup your environmental variables according to Demeteorizer instructions, in my experience all three are needed for the app to function properly on Webfaction:

    export MONGO_URL="mongodb://localhost:[MONGO_PORT]/[DB_NAME]?autoReconnect=true"
    export PORT="[APP_PORT]"
    export ROOT_URL="http://[YOUR_DOMAIN]"
    
  5. Navigate to the folder of your app on webfaction, and use forever to run it in the background:

    forever start main.js
    
  6. Done, the app should be running.

Outras dicas

This is an old post but since I've recently worked through how to get this working myself from start to finish I thought worth sharing... The following github gist is a python script that should be self-explanatory:

https://gist.github.com/mogga/1d038a31e5d998bbcf37

Please submit a pull request if you can improve on it.

I know this is an old question, but this is something I struggled a lot with and that's why I want to contribute. So here are the steps I follow when I deploy a Meteor 1.3 app to WebFaction shared hosting service. You should be familiar with things like command line and ssh. But If you are a Meteor developer, I guess that's not a problem.

TL;DR: If you are looking for a less time consuming option, I created a npm package that follows the steps below: meteorfaction

  1. Get a MongoDB URL. I use and recommend mlab.com for that. Take note of that. If you use mlab, it should be something like mongodb://user:password@ds123456.mlab.com:11122/something.

  2. Create a Node 0.10.43 app on the Webfaction Panel. The reason I choose this version is because the Meteor documentation states that this is the most recent compatible version for the deployed app. Take note of the PORT Number of this app. It should be displayed along with the app info in the panel. Don't forget to create a website for that app.

  3. On your local machine, in you app folder, run the following command: meteor build ./build --architecture os.linux.x86_64. This step should create a app_name.tar.gz file inside a build folder

  4. Upload this .tar.gz file to your webfaction app folder. You can do that using FTP or alternatively you can run the following command inside your local app folder: scp build/app_name.tar.gz webfaction_user@webXXX.webfaction.com:/home/webfaction_username/webapps/app_name/app_name.tar.gz.

Obs: webXXX.webfaction.com is your webfaction server address. webfaction_username is, surprisingly enough, you main webfaction username.

  1. Extract the .tar.gz file you just uploaded. For this step, you need SSH access. Run the following command: ssh webfaction_user@webXXX.webfaction.com for that. Then go to your app directory by running cd webapps/app_name. Once you are there, you can check if the .tar.gz file is there by running ls. If everything is ok, run tar -zxvf app_name.tar.gz.

  2. Step 5 will create a bundle folder in your webfaction app directory. This is where your Meteor app is. Run the following commands: cd bundle/programs/server and then npm install. This will install the app dependencies.

  3. Go back to your Webfaction app folder. We are going to ad some variables to the environment, using the export command. Run: export MONGO_URL=mongodb://user:password@ds123456.mlab.com:11122/something. then export ROOT_URL=yourwebsite.com and finally export PORT=PORT_NUM.

Obs: MONGO_URL is the URL you got from mlab or whatever service you chose (step 1). ROOT_URL is simply your website address. PORT is the port number of your webfaction app (step 2)

  1. run cd bin and then vim start. You just opened the start file for editing. Look up for something like this: nohup /home/webfaction_user/webapps/app_name/bin/node /home/webfaction_user/webapps/app_name/hello-world.js. Use the arrows to send the cursor to that line and press the i key on your keyboard to start editing. Just change hello-world.js to bundle/main.js and then press Esc. Finally, save and quit by typing :wq and hitting Enter.

  2. Now, still on that directory, run the following commands: ./stop and then ./start.

  3. If everything went out ok, you should be able to see your app running. If you see 502 Bad Gateway, go to your app folder on webfaction and run node bundle/main.js. This should give you a hint of what went wrong.

I used the answer from Brunno but with some slight variations for Meteor 1.4 to get it running:

  • Created a Node.js 6.10.3 app instead of Node 0.10.43
  • After running npm install I ran: meteor npm install --save bcrypt
  • on the export steps use the full url on ROOT_URL like: ROOT_URL="http://hostname.domain"
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top