Install NodeJS NPM and OurJS under Debian (Amazon EC2 free tier)

Learn, by newghost Share 1407073960832


Basic Install


1) Choose Amazon free tier EC2 instance

My choice is debian-squeeze-amd64-pvm-2014-07-21-ebs, 

Type t1.micro  Memory (GiB) 0.613

2) Using admin to login SSH

Etc: admin@youripaddress, detail

After log on, switch to root user:

sudo -i

3) Install Node and npm

Follow these stepsnode version 0.10.30

Need pre-install: curl, GCC (4.2+), GNU make (3.81+). python (2.6 or 2.7) and build-essential, detail

apt-get update 
apt-get install curl
apt-get install python
apt-get install gcc
apt-get install make
apt-get install build-essential #(g++ and make included in it, detail)
apt-get install libssl-dev [optional]

Check Version:

$node --version
v0.10.30

4) Install OurJS

Choose a "right" place to run these shells, (etc: /var/www)

npm install ourjs
cp -r node_modules/ourjs ./
chmod 755 ./ourjs/ourjs.sh && ./ourjs/ourjs.sh

If you are trying on Windows, there maybe some errors, like: Failed to locate: "CL.exe". Don't worry it caused by a dependence of mongodb, we don't need that function.

6) Trying at http://localhost:8054

If you want to access your web via public IP, add TCP port 8054 to the security group.




Advance config

1) Install nginx

apt-get install nginx

Update config and save, see an example, edit:

nano /etc/nginx/nginx.conf

Testing config

nginx -c /etc/nginx/nginx.conf -t

Restart nginx

/etc/init.d/nginx restart


2) Auto start ourjs after reboot

Be careful, you'd better create snapshot before doing this.

Create an init script under /etc/init.d, here is and example.

cp /var/www/ourjs/tools/ourjs /etc/init.d
chmod 755 /etc/init.d/ourjs
/etc/init.d/ourjs start

If there is error, check the log and fix it

cat /var/www/ourjs/error.log

Add to the auto-start list

update-rc.d ourjs defaults


3) Disable debug mode

sudo nano /var/www/ourjs/config.magazine.js

debug = false: Means ourjs will cache the templates and do not console log the debug information. This mode will reduce the unnecessary I/O operations.

/*
* Configuration for theme "magazine"
*/
var debug = false;
var WEBSVR_CONFIG = {


4) Setup ftp under Debian

Detail

Add permission of web folder for ftp user 

sudo chmod -R 777 /var/www




19 COMMENTS