The following is on Ubuntu, you may have slightly different default location or bash script names to edit on different Linux disros.
Install Node Version Manager (NVM):
Follow: https://github.com/creationix/nvm and http://www.liquidweb.com/kb/how-to-install-nvm-node-version-manager-for-node-js-on-ubuntu-14-04-lts/
1. Install NVM
1. Install NVM
First make sure the prerequisites are ready:
$ sudo apt-get update
$ sudo apt-get install build-essential libssl-dev
$ sudo apt-get update
$ sudo apt-get install build-essential libssl-dev
Now for the actual install command:
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.1/install.sh | bash
Then I did some additional moving around. It automatically puts things in the users folder. I wanted them globally:
Then I did some additional moving around. It automatically puts things in the users folder. I wanted them globally:
$ sudo mkdir /etc/nvm
$ sudo mv ~/.nvm/* /etc/nvm/
Then change the initialization so it's for all users:
$ sudo vim /etc/bash.bashrc
Add this to the bottom:
export NVM_DIR="/etc/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
export NVM_DIR="/etc/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
Then remove/comment-out the old script location in your user bash:
$ vim ~/.bashrc
Remove or comment-out these two lines - should be at the very bottom:
#export NVM_DIR="/home/ubuntu/.nvm"
#[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
#export NVM_DIR="/home/ubuntu/.nvm"
#[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
2. Logout and log back in again, then test if it's working:
$ nvm [enter]
That should return a list of possible commands + options for using NVM, like this [truncated]:
Node Version Manager
Note: refers to any version-like string nvm understands. This includes:
- full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1)
- default (built-in) aliases: node, stable, unstable, iojs, system
- custom aliases you define with `nvm alias foo`
Usage:
nvm help Show this message
nvm --version Print out the latest released version of nvm
nvm install [-s] Download and install a , [-s] from source. Uses .nvmrc if available
...
...
...
Node Version Manager
Note:
- full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1)
- default (built-in) aliases: node, stable, unstable, iojs, system
- custom aliases you define with `nvm alias foo`
Usage:
nvm help Show this message
nvm --version Print out the latest released version of nvm
nvm install [-s]
...
...
...
3. Now install the latest stable version of node:
$ nvm install stable
Then check the install:
$ nvm ls
That should display something like this:
-> v5.4.0
node -> stable (-> v5.4.0) (default)
stable -> 5.4 (-> v5.4.0) (default)
iojs -> N/A (default)
node -> stable (-> v5.4.0) (default)
stable -> 5.4 (-> v5.4.0) (default)
iojs -> N/A (default)
4. Then set the default engine so it works forever (not sure why this isn't set my default if not set):
$ nvm alias default stable
Check it:
$ nvm ls
That should display something like this:
-> v5.4.0
default -> stable (-> v5.4.0)
node -> stable (-> v5.4.0) (default)
stable -> 5.4 (-> v5.4.0) (default)
iojs -> N/A (default)
default -> stable (-> v5.4.0)
node -> stable (-> v5.4.0) (default)
stable -> 5.4 (-> v5.4.0) (default)
iojs -> N/A (default)
1. Command line with apt-get:
$ sudo apt-get install git
2. Now make the command prompt show the current branch name whenever you are in a git repo directory:
$ sudo vim /etc/profile
Then add the following to the end of the file:
#Show the Current GIT Branch -- if GIT is initialized
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
function proml {
local BLUE="\[\033[0;34m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
local GREEN="\[\033[0;32m\]"
local LIGHT_GREEN="\[\033[1;32m\]"
local WHITE="\[\033[1;37m\]"
local LIGHT_GRAY="\[\033[0;37m\]"
PS1="\u@\h \$(date +%b%d@%I:%M:%S%p) \w$RED\$(parse_git_branch)$GREEN\$ "
PS2='> '
PS4='+ '
}
proml
mesg n
Set up your nodejs website:
1. Make the /var/www/ web directory with proper owners and permissions
$ cd /var
2. Create a folder for each website:
$ mkdir [website-name]
$ git clone .
1. Make the /var/www/ web directory with proper owners and permissions
$ cd /var
$ sudo mkdir www
$ sudo chown -R [your-username]:[your-username] www
2. Create a folder for each website:
$ mkdir [website-name]
$ cd [website-name]
3. Clone your git repo into the current directory (don't forget the period at the end)
$ git clone
That's it!
No comments:
Post a Comment