Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 304 lines (196 sloc) 10.534 kb
1de6d0c @alejandro [master] Added info about the versions installer
alejandro authored
1 # How to install nodester in you personal cloud.
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
2
3 _Nodester - A node.js hosting platform_
4
1de6d0c @alejandro [master] Added info about the versions installer
alejandro authored
5 **If you want you can use the [nodester-installer](http://github.com/nodester/nodester-installer), still work in progress, but functional.**
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
6
7 The only thing that you need to setup your personal instance is `ssh` access- Like this:
8
9 > ssh -t root@yourserver.com
10
1de6d0c @alejandro [master] Added info about the versions installer
alejandro authored
11 ## Dependencies:
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
12
13
14 - bouncy
255ac35 @alejandro [diff] clenup
alejandro authored
15 - node.js (preferible 0.4.11)
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
16 - npm
17 - curl
18 - node.js Modules:
255ac35 @alejandro [diff] clenup
alejandro authored
19 - pool
20 - express
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
21 - request
22 - npm-wrapper
23 - daemon
24 - cradle
25 - coloured
26 - coffee-script
27
1de6d0c @alejandro [master] Added info about the versions installer
alejandro authored
28 ## Installation:
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
29
613d727 @alejandro [master] Added the ulimit record, npm bug fixed and better method to han...
alejandro authored
30 Nodester was/is build on node 0.4.x so we recommend to have as the default version the 0.4.9 one or any of the 0.4.x series installed in your server. Since nodester is able to manage multiple versions of node.js, you can install [`n`]("http://github.com/visionmedia/n") before node.js or after it. We recommend to install before node.js:
e2bd12a @alejandro [master] Fixed indentation & spell error in order to @mintplant feedback
alejandro authored
31
255ac35 @alejandro [diff] clenup
alejandro authored
32 > git clone https://github.com/visionmedia/n.git
e2bd12a @alejandro [master] Fixed indentation & spell error in order to @mintplant feedback
alejandro authored
33 > cd n
34 > make
35 > make install
36
37 Check if `n` is installed correctly, otherwise (inside `n` dir):
38
39 > sudo cp bin/n /usr/local/bin
40
41 Then you can use `n` as a node.js version manager, like this:
42
43 > n 0.4.9 #which is currently used by nodester
44
45 **note**: It's a good practice to install any node.js version as root.
46 Then go to [here](#a)
47
48 If you don't want to git#clone the repo, follow these instructions:
49
50 First of all you'll need some packages to make nodester work, the only one that you need to manually install are node.js, npm, curl and forever as follows:
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
51
52 > Install node.js (0.4.x recommended) as you prefer (wget/pkg/git clone)
53
54 Install npm:
55
56 > curl http://npmjs.org/install.sh | sh
57
58 Install n (for multiple version support):
59
60 > npm install n -g
61
62 Then install again node 0.4.x as n child:
63
64 > n 0.4.x
65
66 The `n` command will handle all the installation process from the version, this is done from this way, so we after can use `n use 0.4.x` as unique method to run application. Meanwhile you are install node again trough `n` setup the user and the permissions needed to run your personal instance of `nodester`.
67
613d727 @alejandro [master] Added the ulimit record, npm bug fixed and better method to han...
alejandro authored
68 <a name="a" />
e2bd12a @alejandro [master] Fixed indentation & spell error in order to @mintplant feedback
alejandro authored
69 ### Create the environment
70
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
71 **Create a user and group to run nodester as (do this as root)**
72
73 > sudo su -
74 > groupadd nodester
75 > useradd -d /var/nodester -c "nodester" -g nodester -m -r -s /bin/bash nodester
76 > passwd nodester
77
78 Then login to the account `nodester` and ensure that .ssh/authorized_keys exists:
79
9dd2590 @alejandro [master] Fixed bad link on README.md and some bad typos over install.md
alejandro authored
80 > ssh nodester@yourhost
81 > cd ~
82 > mkdir .ssh
83 > touch .ssh/authorized_keys
84 > chmod go-rwx .ssh/authorized_keys
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
85
86 Update sudoers to allow running of the proxy on port 80 (do this as root), and umount of git repos:
87
9dd2590 @alejandro [master] Fixed bad link on README.md and some bad typos over install.md
alejandro authored
88 > sudo visudo
89
90 And add the following lines:
91
3326d5f @alejandro [master] Added proxy_table.json example and typos fix on install.md
alejandro authored
92 nodester ALL = NOPASSWD: /var/nodester/nodester/bin/proxy_start.sh *
93 nodester ALL = NOPASSWD: /var/nodester/nodester/bin/proxy_stop.sh
94 nodester ALL = NOPASSWD: /var/nodester/nodester/bin/app_start.sh *
95 nodester ALL = NOPASSWD: /var/nodester/nodester/bin/app_stop.sh *
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
96
97 Export paths (to make npm work):
98
9dd2590 @alejandro [master] Fixed bad link on README.md and some bad typos over install.md
alejandro authored
99 > cd ~
100 > echo -e "root = ~/.node_libraries\nmanroot = ~/local/share/man\nbinroot = ~/bin" > ~/.npmrc
101 > echo -e "export PATH=\"\${PATH}:~/bin\";" >> ~/.bashrc
102 > source ~/.bashrc
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
103
104 *(Optional)* Sometimes at deploying with previous versions of npm can be difficult and annoying, **This part is a hack to use the old npm with the new node until certain packages can catch up and be installed with npm@0.3.x**
105
9dd2590 @alejandro [master] Fixed bad link on README.md and some bad typos over install.md
alejandro authored
106 > mkdir ~/src
107 > cd src
108 > git clone git://github.com/isaacs/npm.git ./npm
109 > cd npm
110 > git checkout origin/0.2
111 > make dev
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
112
113 *(Optional)* Fetch 0.2.6 version of node for npm
114
9dd2590 @alejandro [master] Fixed bad link on README.md and some bad typos over install.md
alejandro authored
115 > cd ~/src
116 > sudo mkdir -p /usr/local/n/versions/
117 > wget http://nodejs.org/dist/node-v0.2.6.tar.gz
118 > tar -vzxr node-v0.2.6.tar.gz
119 > cd node-v0.2.6
120 > ./configure --prefix=/usr/local/n/versions/0.2.6
121 > make
122 > sudo make install
123
124 > cd ~/bin
125 > cp npm\@0.2.18 nodester-npm
126 > vim nodester-npm
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
127
9dd2590 @alejandro [master] Fixed bad link on README.md and some bad typos over install.md
alejandro authored
128 Replace `'#!/usr/bin/env node'` with `'#!/usr/local/n/versions/0.2.6/bin/node'`
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
129
130
131 ## Install dependencies
132
133 Install node-module dependencies (do this as nodester)
134
9dd2590 @alejandro [master] Fixed bad link on README.md and some bad typos over install.md
alejandro authored
135 > for X in pool express npm-wrapper request daemon forever cradle coloured; do npm install ${X}; done
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
136
137 Get nodester (do this as nodester)
138
9dd2590 @alejandro [master] Fixed bad link on README.md and some bad typos over install.md
alejandro authored
139 > cd ~
140 > git clone git://github.com/nodester/nodester.git
141 > cd nodester
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
142
143 Ensure that the ownership of nodester/proxy is all root for security (do this as root)
144
9dd2590 @alejandro [master] Fixed bad link on README.md and some bad typos over install.md
alejandro authored
145 > cd /var/nodester
146 > sudo chown -R root:root nodester/proxy
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
147
148 Install the git folder shell to restrict git to per user folders (do this as root)
149
9dd2590 @alejandro [master] Fixed bad link on README.md and some bad typos over install.md
alejandro authored
150 > cd /var/nodester/nodester
151 > sudo cp scripts/git-shell-enforce-directory /usr/local/bin
152 > sudo chmod +x /usr/local/bin/git-shell-enforce-directory
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
153
154 ## Configuration
155
156 User: `nodester` (`ssh nodester@...`)
157
158 You'll need to either install CouchDB or get a CouchOne|iriscouch|cloudant account, then copy `nodester/example_config.js` to `nodester/config.js`, and edit the settings in nodester/config.js, basically in this file you define the couchdb url `git` dir and `app` dir also you define the `couchdb` url, the email support, your personal domain and the one of the most important parts the `proxy_table`. You definetely want to take a look to all the options.
159
255ac35 @alejandro [diff] clenup
alejandro authored
160 The example [config.js](http://github.com/nodester/nodester/tree/master/example_config.js) looks like this:
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
161
9dd2590 @alejandro [master] Fixed bad link on README.md and some bad typos over install.md
alejandro authored
162 // config.js
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
163 exports.opt = {
164 couch_user: 'alejandromg',
165 couch_pass: 'alejandromg_password',
166 couch_host: 'nodester.iriscouch.com',
167 couch_port: 5984,
168 couch_prefix: 'nodester',
169 couch_tables: ['coupons', 'nodefu', 'nextport', 'apps', 'repos', 'aliasdomains', 'password_resets'],
170 home_dir: '/var/nodester', // if you did all the steps above you don't need to change this
171 app_dir: '/var/nodester/nodester', // and this
172 git_home_dir: '/git', // we prefer root dirs
173 apps_home_dir: '/app', // same here
174 public_html_dir: '/var/nodester/nodester/public',
175 proxy_table_file: '/var/nodester/var/proxy_table.json',
176 tl_dom: 'example.co',
177 api_dom: 'api.example.co',
178 git_user: 'nodester',
179 git_dom: 'nodester.example.co',
180 coupon_code: 'test', // The initial coupon code
181 blocked_apps: ['www', 'api', 'admin', 'support', 'blog', 'site'],
182 restart_key: 'test', // this is the key you'll need after in gitrepoclone.sh
183 userid: 'nodester',
184 app_uid: 100,
185 enable_ssl: false, // Currently SSL forward to the app/api, when I have a wildcard cert to test, then all apps can have SSL.
186 ssl_ca_file: '',
187 ssl_cert_file: '',
188 ssl_key_file: '',
189 node_base_folder: '/opt/node-v0.4.9_npm_v1.0.3',
190
191 //Amazon SES mail info
192 SES: {
193 AWSAccessKeyID: 'ACCESSKEY',
194 AWSSecretKey: 'SECRETKEY',
195 ServiceUrl: 'https://email.us-east-1.amazonaws.com',
196 }
197 };
198
199 Also copy `scripts/example_gitrepoclone.sh` to `scripts/gitrepoclone.sh` and update it with the key you specified in `config.js`.
200
613d727 @alejandro [master] Added the ulimit record, npm bug fixed and better method to han...
alejandro authored
201 ### The chroot template
202
203 The way in how nodester works is pretty straigthforward, so, when a user does a `nodester app restart|start` nodester takes the `node_base_folder` param and it use it to create|mount the sandbox for the app, the `node_base_folder` has the whole environment in which the node-versions are installed and everything that an app needs to work. Soon we are going to publish an example of this environment. So you can install it easily.
204
6f8cf72 @alejandro [merge] Upgrade branch into master
alejandro authored
205 Also you can take a look at [this](https://help.ubuntu.com/community/BasicChroot)
206
1de6d0c @alejandro [master] Added info about the versions installer
alejandro authored
207 ### Multiple versions of node:
208
209 User: `root`
210
211 We've created a script to install all the versions of node with a single line:
212
213 > cd /var/nodester/nodester/
214 > bin/install_versions.js --run
215
255ac35 @alejandro [diff] clenup
alejandro authored
216 **warning**: As you may know compiling node.js can take some time to end, so imagine installing ~20 versions of node.js from once, that would be awful and you'll better get some coffee and wait. So, you can add something like this:
1de6d0c @alejandro [master] Added info about the versions installer
alejandro authored
217
218 > bin/install_versions.js -v 0.4.9
219
220 Which can be done also with `n` directly: `n 0.4.9` for example.
221
222 Programmatically you can also require the `install_versions.js` module, and then install the version you want:
223
224 // installer.js
225 var installer = require('./bin/install_versions.js');
226 installer('0.5.9')
227
228
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
229 ### Setting up the database
230
231 user: `nodester`
232
233 First you'll need to seed the CouchDB tables:
234
235 > cd ./nodester/scripts/couchdb/
3326d5f @alejandro [master] Added proxy_table.json example and typos fix on install.md
alejandro authored
236 > ./create_all_couchdb_tables.js
237 > ./create_all_couchdb_tables.js
238 > ./setup_default_views.js
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
239
240 ### Finals steps
241
242 user: `nodester`
243
244 If you did all the steps correctly, you are ready to go, but first let's create the forever dir and the `proxy_table.json`:
245
246 > cd ~
247 > mkdir -p .forever/logs
248 > mkdir -p nodester/var/
249 > echo '{"example.co":4001, "api.example.co":4001}' > nodester/var/proxy_table.json
250
e2bd12a @alejandro [master] Fixed indentation & spell error in order to @mintplant feedback
alejandro authored
251 Also you might want to chown the proxy_table to nodester:
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
252
253 > sudo chown $USER -R nodester/var/proxy_table.json
254
1de6d0c @alejandro [master] Added info about the versions installer
alejandro authored
255 ## Ready, set, GO!
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
256
257 Start up the proxy and main/api app (do this as nodester):
258
259 > cd nodester
260 > ./bin/app_start.sh && sudo ./bin/proxy_start.sh
261
262 Test the web frontend at 127.0.0.1:80 or example.co, and the api too api.example.co
263
264 #### Create a user
265
266 The coupon can be the one you define in `config.js`.
267
268 > curl -X POST -d "coupon=mycoupon&user=testuser&password=123&email=chris@nodester.com&rsakey=ssh-rsa AAAAB3NzaC1yc..." http://example.co/user
269
270 #### Create an app
271
272 Creates nodejs app for hosting (requires basic auth and returns the port address required for use along with a git repo to push to):
273
274 > curl -X POST -u "testuser:123" -d "appname=a&start=hello.js" http://api.example.co/app
275
276 This action return the git repo url, so, you may want to copy that and add it to the `remote` in your local git repo.
277
278 {"status":"success","port":10029,"gitrepo":"nodester@nodester.example.co:/git/test/30-edd3ed1cc9998703e507b56cb1c495e0.git","start":"app.js","running":false,"pid":"unknown"}
279
280 Make changes to your repo and:
281
282 ### Start the app
283
284 > curl -X PUT -u "testuser:123" -d "appname=a&running=true" http://api.example.com/app
285
286 ### Test the app
287
288 GOTO-> appname.example.co
289
1de6d0c @alejandro [master] Added info about the versions installer
alejandro authored
290 ### Rejoice!
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
291
292
293 Sidenotes:
1de6d0c @alejandro [master] Added info about the versions installer
alejandro authored
294
bb3f58c @alejandro [master] Better looking install.md
alejandro authored
295 **More info about the REST API: http://nodester.com/api.html#rest**
1de6d0c @alejandro [master] Added info about the versions installer
alejandro authored
296
613d727 @alejandro [master] Added the ulimit record, npm bug fixed and better method to han...
alejandro authored
297 Don't like the REST API way? Try the [`nodester-cli`](http://github.com/nodester/nodester-cli).
298
299 ### Credits
300
301 - [Nodester]("http://nodester.com")
6f8cf72 @alejandro [merge] Upgrade branch into master
alejandro authored
302 - `n` By [TJ Holowaychuk]("http://github.com/visionmedia")
303
Something went wrong with that request. Please try again.