-
Notifications
You must be signed in to change notification settings - Fork 0
Setting up your dev environment on Windows with vagrant
While it's possible to develop against node on Windows natively, it is really a lot more work, as Cygwin doesn't give the full *nix support which makes development so much easier in that environment, esp. for web development. Windows does however give a good range of Editing and Designing front end tools.
This guide will get you setup on your windows machine, with the application running on Ubuntu in a Vagrant VM box on your desktop.
You shouldn't need ftp either, as we will use git to publish from your windows client to the vagrant box
Full setup instructions can be found here
- Install Oracle Virtual Box
- Install Vagrant
There are several pre-built vagrant vm boxes / images available at http://www.vagrantbox.es We will be using Ubuntu 11.10 as our default so let's first create a new local directory where we are going to run our vagrant vm in:
From your terminal / command line:
mkdir vagrant10x
cd vagrant10x
vagrant box add ubuntu11.10 http://timhuegdon.com/vagrant-boxes/ubuntu-11.10.box
vagrant init ubuntu11.10
Open the **Vagrantfile **in your favorite text editor Uncomment the line (remove the leading "#"), and take note of the IP address there - or change it to one you want.
config.vm.network :hostonly, "192.168.33.10"
Save and close the editor.
To launch it, simply type
vagrant up
to connect to it:
vagrant ssh
To halt it:
first Ctrl-C to exit SSH
vagrant halt
First - let's launch and connect to the VM
vagrant up
vagrant ssh
sudo apt-get install build-essential
sudo apt-get install git
sudo apt-get install mongodb
sudo apt-get install redis-server
sudo apt-get install python-software-properties
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm
A full walkthrough is [here] (https://help.github.com/articles/set-up-git#platform-linux)
Once you have created your new SSH public key, you need to copy the contents of the ~/.ssh/id_rsa.pub file to Steve who will add this VM as a deploy point to the 10xEngineer.me repository. This is different from your collaborator access that you have setup for windows as it is pull only - you can't contribute code from here back to the github repo.
ssh -T [email protected]
You should get a message at the end of this text saying:
"Hi 10xEngineer/10xEngineer.me! You've successfully authenticated, but GitHub does not provide shell access."
You now have access to github on this VM. Next, let's clone the repository down to this box:
git clone [email protected]:10xEngineer/10xEngineer.me.git
Once this is cloned locally, you can now change into that directory and install the node.js packages
cd 10xEngineer.me
npm install -d
To validate that all the packages have installed ok - let's check them
npm list
If you see any packages listed in RED - with UNMET DEPENDENCY errors - then you just need to install them manually one by one.
For each missing package, e.g. log4js type:
npm install log4js
if it fails - sometimes with a permissions warning, then re-try with :
sudo npm install log4js
Until all packages are listed green in the "npm list"
To start it simply type
node server.js
You will see the following output when it first runs
[2012-06-07 01:48:43.829] [INFO] app - Initializing models
[2012-06-07 01:48:45.242] [INFO] app - Express server listening on port 3000 in development mode
[2012-06-07 01:48:46.681] [INFO] console - info - 'socket.io started'
[2012-06-07 01:48:47.813] [INFO] app - Database connection established.
[2012-06-07 01:48:48.445] [INFO] app - Run 1 times.
[2012-06-07 01:48:49.072] [INFO] app - Migrating the database from version 1 to 3
[2012-06-07 01:48:49.167] [INFO] app - Migrating the database from version 2 to 3
[2012-06-07 01:48:49.209] [INFO] app - Database has been successfully migrated to version 2
[2012-06-07 01:48:49.429] [INFO] app - Deleted all the users
[2012-06-07 01:48:49.981] [INFO] app - Database has been successfully migrated to version 3
Congratulations - you are now running the 10xEngineer.me front end in your vagrant box on your desktop
Open up a second command line terminal, if needed - so you can leave your vagrant box running 10xEngineer.me
You also need to Setup github access on Windows on your windows machine - as a collaborator. You need to change some git configuration settings for windows in order to deal with differences in permissions handling and line endings.
- git config --global core.autocrlf true
- see Windows line endings for more info
- git config --global core.fileMode false
- see git config options for more info
- Send your github id to Steve, to get added as a collaborator on the repository
You will be editing your local development copy of the 10xEngineer repo, so follow the above instructions to setup your github access - (similarly to what you did for the Linux Vagrant box).
-
From the instructions above, add your WINDOWS SSH key (in your Windows id_rsa.pub) file to the SSH Key section under Admin on your github account.
-
Test your connection to github.
ssh -T [email protected]
If all is fine, you should see the same Welcome message as before.
Clone the repository down to your windows machine.
git clone [email protected]:10xEngineer/10xEngineer.me.git
Congratulations - you are now ready to do hard-core windows / node.js development on your windows machine
Make sure to follow the development guidelines in the 10xEngineer.me wiki
To push changes of your local branch back to the shared repository
git push origin my_branch_name
Then to pull changes down to the local vagrant box, you need to restart the node.js server In your vagrant box SSH session:
git pull
Make sure that you are working on your branch here - so you should switch on your first pull
git checkout my_branch_name
Now, restart node.js server to see the new changes
node server.js
Remember - the ip address you noted down before, use this for your URL
You should now see the 10xEngineer.me front page.