-
Notifications
You must be signed in to change notification settings - Fork 11
How to start develop with node js on linux from windows
Linux is awesome.
Here you can find some basic knowledge of Linux usage to start running node.js
Please notice this guide is not tested but it is probably a very very good hint.
Below I propose a way I have found it a convenient way to work:
I develop on windows and on Linux. I do it by running a Linux virtual machine on vmware server.
I have installed Linux with open ssh server and Samba (a network files sharing service compatible with windows).
I like to use PsPad to edit files and Putty for ssh (in putty I set window lines scrollback to 20000)
I have started to use samba on all my servers i find it easier then ftp.
If you use samba you will probably need a secure password.
How to choose a secure password?: I use the sentence method! the password is a sentence of words connected without spaces. for example: iamusingdevserver or ilovemywife iambatman. choose a long password the longer the better.
You might want to download some virtual pc software like:
- Vmware – vmware server – it is free, or vmware workstation if you like (same functionality different interface and costs money).
- Sun, virtual-box – witch is very good and free also
- Microsoft, Virtual pc – is also free.
probably there are more virtualization programs, instead you might want to rent a vps or set it up on your real server.
if you decide to setup virtual machine on windows it works faster if you store virtual machine files in a compressed folder. To do so create a folder somewhere for example: d:\vm\ right click on it and select properties, click advanced, and check ‘make its contents compressed to save disk space’. it just fastens reading and writing of large empty files.
To create a new virtual machine.
Open your virtual pc software and create new virtual machine.
Select that you will install Ubuntu Linux 32 bit (to install 64bit Linux on a virtual machine you should also have a CPU supporting 64 bit – not OS just cpu)
Select a 10 GB disk and 256 mb of RAM memory or even less.
Usually it does not take more then 64 to run and not more then 120 to boot.
on a production system because v8 reserves just for fun 850 mb of memory at start. or virtual memory on a computer with less memory.
so it might be good idea to run it on a computer with at last 900mb of memory for it to run super fast but is not a requirement it runs in any condition.
Download Ubuntu linux .iso file it is a cdrom disk image file.
In your virtual pc software mount it as cdrom and power on the virtual pc.
Then install the linux. as simple as clicking next many times and makeing some choices.
When you done installing the Linux, then login.
first thing you do is to set the root user password (root is linux administrator account).
to do it you type:
sudo su
passwd
logout and login as root.
to install packages on Linux of Debian flavor like Ubuntu
you use apt-get or aptitude tool they are basically the same.
aptitude install openssh-server
To be able to Copy-Pase from browser to linux you will need to connect to it with ssh.
I prefer the Putty for windows ssh client
You might need to know what IP address your new Linux received . you can see it if you type
ifconfig
Now connect to your Linux with Putty. login as root.
you will love to copy and paste from putty because it will speed up your work on Linux tremendously.
- use mouse left click and select some text – it copies the text to clipboard
- use mouse right click – it pastes the text from clipboard
To have easy file access you might want to install samba service.
aptitude install samba
before samba can work you have to configure it:
samba users need to be added to samba manually to do so you execute:
smbpasswd -a root
[type your password.]
To add a network share you have to edit samba config file.
to that you can use the Nano text editor.
nano /etc/samba/smb.conf
go to the end of the file with keyboard page down until the end.
then add some newlines by pressing the enter key,
copy the following text, and right click to paste it inside the editor.
[root]
comment = System Share
path = /
guest ok = no ; or yes if it is in vmware
browseable = yes
create mask = 0777
directory mask = 0777
read only = no
also you might want to out comment all printer configurations with ; at the beginning of the line.
to save the file and exit from the nano editor you press Control + X
… see the shortcut keys at bottom of screen.
to have your configuration changes take effect you need to restart samba
to restart samba execute:
restart smbd
to use samba windows network files share you type from windows run command or in address bar in windows explorer:
\\hostname_or_ipaddress_of_your_server
then you type a password and you can use it.
it might feel at first unfamiular but you can do:
\\mywebsite.com
and get the folder in windows explorer
go to /var/www and work there or in some other folder if you know what your are dong.
you probably noticed that with node.js, git and github are very popular.
to install git from ssh type:
aptitude install git-core
how to use github: http://help.github.com/
after you register on github:
http://help.github.com/creating-a-repo/
http://help.github.com/msysgit-key-setup/
to install node.js go to user home folder (a short cut for the current user dir on linux is the ~ sign)
cd ~/
to download nodejs browse to website of node.js
http://nodejs.org/#download
find the download link.
right click on download url and copy url shortcut
you will have copied
http://nodejs.org/dist/node-v0.1.99.tar.gz
in ssh type:
wget , and right click, you will have:
wget http://nodejs.org/dist/node-v0.1.99.tar.gz
to extract the file you type
tar -vxf [and press tab to use auto complete]
the result will be:
tar -vxf node-v0.1.99.tar.gz
now enter to the nodejs’s folder.
to do so type:
cd no [and press tab several times]
you will have:
cd node-v0.1.99
then do like described in the node.js manual.
those are the usual steps of compiling and installing a software from source on linux:
./configure
make
make install
(side note: the default modules folder is at : /usr/local/lib/node )
notice the ./ before configure
it means to execute a script in the current folder
to make script executable (if it is not) you can type chmod +x yourfilename
then you can do ./yourfilename
how to use autorestart continued in README file.
now you know how to install software , this way you can install mongodb and nginx.
hint: if you will install php5-cgi for nginx , first install php5-cli to prevent it installing apache.