Skip to content

Instantly share code, notes, and snippets.

FreeBSD 10 Nodejs setup with nginx, mongodb, redis and monit

This my receipe for installing a complete nodejs server on FreeBSD 10. The parameters used in this configuration are for a very small private server that I use for demo purpose only, so for a production server, you should somehow set the limits in pair with your ressources.

I use monit so I don't have to write rc scripts for node and it should take care of process lifecycle management for me. Alternatives exists such as supervisord or circus.

Installing mongodb

dumpdev="AUTO"
zfs_enable="YES"
sshd_enable="YES"
local_unbound_enable=yes
ifconfig_igb0="inet 37.XXX.XXX.166 netmask 255.255.255.0 broadcast 37.XXX.XXX.255"
ifconfig_igb0_alias0="inet 178.XX.XX.6 netmask 255.255.255.255 broadcast 178.XX.XX.6"
# Custom loopback interface
cloned_interfaces="lo666"
ifconfig_lo666_alias0="inet 10.6.6.6 netmask 255.255.255.255"
ifconfig_lo666_alias1="inet 10.6.6.7 netmask 255.255.255.255"
☺ npm list 2.1.0 master f95f43a ✗""
npm WARN unmet dependency /Users/khinester/Sandboxes/Business/continentalclothing.com/dev/node_modules/gulp-sass/node_modules/node-sass requires mocha@'1.18.x' but will load
npm WARN unmet dependency /Users/khinester/Sandboxes/Business/continentalclothing.com/dev/node_modules/mocha,
npm WARN unmet dependency which is version 1.19.0
node-express-blade@0.0.1 /Users/khinester/Sandboxes/Business/continentalclothing.com/dev
├─┬ assert@1.1.1
│ └─┬ util@0.10.2
│ └── inherits@2.0.1
├── async@0.6.2
├─┬ aws-sdk@2.0.0-rc.15 extraneous
☺ gulp serve 2.1.0 master f90b08a""
[gulp] Using gulpfile ~/Sandboxes/Business/continentalclothing.com/node-blade-boiler-template/gulpfile.js
[gulp] Starting 'sass-dev'...
[gulp] Starting 'coffee-dev'...
[gulp] Starting 'nodemon'...
[gulp] Finished 'nodemon' after 871 ms
[gulp] [nodemon] v1.0.19
[gulp] [nodemon] to restart at any time, enter `rs`
[gulp] [nodemon] watching: *.*
[gulp] [nodemon] starting `node run.js`
☺ gulp serve 2.1.0 master f90b08a ✗""
[gulp] Using gulpfile ~/Sandboxes/Business/continentalclothing.com/node-blade-boiler-template/gulpfile.js
[gulp] Starting 'sass-dev'...
[gulp] Starting 'coffee-dev'...
[gulp] Starting 'nodemon'...
[gulp] Finished 'nodemon' after 984 ms
[gulp] [nodemon] v1.0.19
[gulp] [nodemon] to restart at any time, enter `rs`
[gulp] [nodemon] watching: *.*
[gulp] [nodemon] starting `node run.js`
@nkhine
nkhine / gist:f620f8bdc0fb613b7b59
Last active August 29, 2015 14:02
nginx.conf
#user nobody;
worker_processes 4;
worker_priority 15;
error_log logs/error.log notice;
pid logs/nginx.pid;
events {
use kqueue; # event method, kqueue for FreeBSD and OpenBSD
worker_connections 1024; # number of parallel or concurrent connections per worker_processes
}
1) Load the u3g(4) driver:
# kldload u3g
# kldstat
Id Refs Address Size Name
...
7 1 0xffffffff81b6e000 5ffb u3g.ko
2) Set the driver to load at boot:
@nkhine
nkhine / gist:fa51bb6cb6f958efd80f
Last active August 29, 2015 14:05
fabric entires
100% Certified Organic Cotton Jersey 155 g / 4.6 oz.
100% Certified Organic Cotton Jersey 145 g / 4.3 oz.
100% Certified Organic Cotton Jersey 155 g / 4.6 oz.
100% Certified Organic Cotton Jersey 155 g / 4.6 oz.
100% Certified Organic Cotton Jersey 155 g / 4.6 oz.
100% Certified Organic Cotton Pique 180 g / 5.3 oz.
100% Certified Organic Cotton Pique 180 g / 5.3 oz.
100% Certified Organic Cotton Jersey 155 g / 4.6 oz.
100% Certified Organic Cotton Jersey 155 g / 4.6 oz.
@nkhine
nkhine / gist:19cda0ea9fa2509a872a
Created September 12, 2014 07:35
iconv npm issues
npm http GET https://registry.npmjs.org/iconv
npm ERR! tar.unpack untar error /Users/khinester/.npm/iconv-lite/0.4.4/package.tgz
npm http GET https://registry.npmjs.org/growl
npm http 304 https://registry.npmjs.org/globule
npm ERR! Error: ENOENT, lstat '/Users/khinester/Sandboxes/Business/continentalclothing.com/node-blade-boiler-template/node_modules/nodemailer/node_modules/mailcomposer/node_modules/mimelib/node_modules/encoding/node_modules/iconv-lite/README.md~'
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
@nkhine
nkhine / gist:e654b53905ff9f119cca
Created September 12, 2014 08:57
paypal sandbox request
Reply >>>> {
"id": "PAY-5DC727074K9372822KQJLKOI",
"create_time": "2014-09-12T08:56:25Z",
"update_time": "2014-09-12T08:56:27Z",
"state": "approved",
"intent": "sale",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [
{