Skip to content

Instantly share code, notes, and snippets.

@mamiu
Last active March 4, 2017 22:43
Show Gist options
  • Save mamiu/cc792b805eec59b224c9 to your computer and use it in GitHub Desktop.
Save mamiu/cc792b805eec59b224c9 to your computer and use it in GitHub Desktop.
Install HabitRPG on Uberspace.

##This is a guide to install HabitRPG on an Uberspace.

###Installation

First you have to create a folder which is accessable from the web (e.g. habitrpg.yourdomain.com) and then move to it. In this folder execute

git clone https://github.com/HabitRPG/habitrpg.git .

After that, you have to download some dependencies with:

npm install grunt-cli bower phantomjs
npm install

Now you have all necessary files on your server.

###Configuration

To configure HabitRPG for uberspace you have to copy the config.json.example to config.json with

cp config.json.example config.json

Now look for a free port between 61000 and 65536. (Node apps need a specific port, where they can listen). To check which ports are used you can issue this command:

netstat -tulpen | column -t | grep ':6[1-5][0-9]\{3\}'

Of course we need to redirect the traffic from your domain to the port your app will be running on. So create a file called .htaccess and put the following in it (remember to correct the port to the one, you've chosen):

RewriteEngine On
RewriteRule ^(.*) http://localhost:<YOUR_PORT>/$1 [P]

We also need a database. HabitRPG uses mongodb, so we have to set up a mongodb instance. On an Uberspace that's a no-brainer. ;) Just hit

uberspace-setup-mongodb

Keep the data wherever you want, but keep it. (You can check the mongo instance with mongo admin --port <YOUR_MONGO_PORT> -u '<YOUR_MONGO_USERNAME>' -p '<YOUR_MONGO_PASSWORD>' [replace the <YOUR_MONGO_*>-tags with the output from uberspace-setup-mongodb]. Ctrl-C to exit.)

Ok, lets open the config.json file and edit following lines:

  • The PORT to the port you've chosen
  • The NODE_DB_URI to "mongodb://<YOUR_MONGO_USERNAME>:<YOUR_MONGO_PASSWORD>@localhost:<YOUR_MONGO_PORT>/db?authSource=admin" (replace the <YOUR_MONGO_*>-tags with the data from uberspace-setup-mongodb.
  • The SESSION_SECRET to a random key with 50 characters (alphanumeric)

If you want, you can change the remaining configurations later, but for now it's enough to get HabitRPG running.

###Bring it to life

npm install

(Nothing more to say)

######Have fun!

@V0IDNIL
Copy link

V0IDNIL commented Apr 18, 2016

Yeah, unfortunately this doesn't work for me either.

@perguth
Copy link

perguth commented Jun 29, 2016

I get a 500 when using the reverse proxy. Something within express router revolts... Need to investigate... I uncommented a comment... that was the reason for the 500.

@perguth
Copy link

perguth commented Jun 29, 2016

The important takeaway here is ?authSource=admin for the MongoDB connection.

@gruentee
Copy link

Worked fine for me, thanks!

@gruentee
Copy link

gruentee commented Dec 4, 2016

Has anyone tried running Habitica in production mode? When I set NODE_ENV to production in config.json I get redirected to the BASE_URL.

@gruentee
Copy link

For the latest version of Habitica npm >= v.3.10.10 is required. Therefore on uberspace you currently need to install Node & npm via nvm.

@gruentee
Copy link

Moreover one needs to use a recent version of GCC in order to install (compile) bcrypt >= v1.0.3.

export PATH=/package/host/localhost/gcc-4/bin:$PATH
# then install bcrypt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment