Setting up Sage on Windows 8.1

In order to get Sage working properly on Windows 8.1, you’ll need to complete these steps
before your first ‘vagrant up’

As of 8/5/15, this works with lastest release of Trellis, Bedrock, & Sage.

Requirements:

Windows 8.1 PC Host
Vagrant 1.7.4
Virtualbox 4.3.30
Vagrant-hostsupdater plugin
vagrant-winnfsd
Putty SSH Client (Windows doesn’t come with one)
PuttyGen (Generates SSH Keys)

***Symlinks did not work when using VirtualBox 5.0.0
I believe it has something to do with the vagrant guest additions, but I’m no expert.
While running vagrantup, you’ll see the guest additions are only up to Vbox 4.3.10

By default, VirtualBox disables symlinks for security reasons. So we need to enable this
in our Vagrantfile so we can use symlinks in the next steps.

config.vm.provider "virtualbox" do |vb|
    vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"]
    vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/current", "1"]
end

Now we need to enable symlinks between (L)ocal and ®emote machines on our Windows host.
Run the following command in an admin command prompt and then restart your machine
for it to take effect. This command enables all forms of symlinks between local and
remote machines.

fsutil behavior set SymlinkEvaluation L2L:1 R2R:1 L2R:1 R2L:1

You can now run ‘vagrant up’. Make sure you do this in an admin command prompt.

The above instructions are a modified version of the information contained at
http://blog.prolificinteractive.com/2015/01/21/getting-vagrant-nodejs-windows-play-well-together/

The newest release of the roots setup requires an SSH Key in order to access the Virtual Machine.
People who don’t use Windows can type ‘vagrant ssh’ and that activates an ssh session in the cmd prompt and the program already knows the location of the SSH key.

However, if you use Windows, when you run ‘vagrant ssh’ Vagrant will instead output SSH authentication info which you can use with your favorite SSH client, such as PuTTY. An SSH client is generally not distributed with Windows by default.

PuTTY may not recognize the insecure_private_key provided by vagrant as a valid private key. To remedy this, first grab the PuTTYgen app. Then use PuTTYgen and import the insecure_private_key (found in the .vagrant.d dir in your home directory) and save a ppk file from that private key. Use the ppk file instead of the default one when SSHing into your vagrant box.

Open the PuttyGen program, select ‘Conversions’ from the top menu, and then select 'Import Key’
You should find your key in

C:\Users\YOURNAME\Documents\GitHub\EXAMPLE.com.vagrant\machines\default\virtualbox\private_key

Select ‘Save private key’ and save it without a passphrase.

I saved the file as private_key_putty.ppk

In PUTTY navigate to Connection > SSH > Auth in the lefthand category menu.

Click browse on the ‘Private key file for authentication’ & select your private key file from earlier.

After you enter all the proper details, you should save these settings as a Session in putty, so you do not have to do this everytime.

http://docs-v1.vagrantup.com/v1/docs/getting-started/ssh.html


In your VM via SSH

mkdir /srv/www/sitename/node_modules
sudo chown vagrant:www-data /srv/www/sitename/node_modules

Copy the package.json from your theme folder and put it in /srv/www/sitename

cp /srv/www/sitename/current/web/app/themes/themename/package.json /srv/www/sitename
sudo chown vagrant:www-data /srv/www/sitename/package.json

Get the latest version of nodejs & npm

curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
sudo apt-get install nodejs 

Clear npm cache and remove any node_modules folder that may have been in your theme folder

cd /srv/www/sitename/current/web/app/themes/themename
npm cache clear && rm -rf node_modules

Now we need to bypass Window’s 260 character file length limit. Because of npm’s deeply nested folder structure, getting over 260 character paths is pretty likely. To get around this, we will use a symlink so npm directories are not written back to the Window’s host machine.

ln -s /srv/www/sitename/node_modules /srv/www/sitename/current/web/app/themes/themename/

Follow the instructions at this link to get npm working without using sudo
https://docs.npmjs.com/getting-started/fixing-npm-permissions

Install gulp and Bower globally with

npm install -g gulp
npm install -g bower

Navigate to the new node_modules directory and run the npm install

cd /srv/www/sitename/
npm install

Navigate to the theme directory and install bower

cd /srv/www/sitename/current/web/app/themes/themename/
bower install

Hope I made this clear enough.
You will need to do this on every first ‘vagrant up’ and after a ‘vagrant destroy’ per virtual machine.

After your first ‘vagrant up’

Install vagrant winnfsd - which enables nfs on Windows

$ vagrant plugin install vagrant-winnfsd

Open your Vagrantfile and comment out

config.vm.synced_folder local_site_path(site), remote_site_path(name), owner: 'vagrant', group: 'www-data', mount_options: ['dmode=776', 'fmode=775']

And add the following line below it

config.vm.synced_folder local_site_path(site), remote_site_path(name), type: 'nfs'

This is needed to give the development server a major performance boost! Your development server will easily take 4-5 seconds to load pages without this.

Then run

vagrant reload --provision

If you enable nfs in your vagrantfile before your first vagrant up, you will receive an error. So you will need to toggle between the original line and the new line.

1 Like

Check out my post here

I have created a script that handles most things that need to be configured in order to setup the sage theme and deploy to staging and/or production server.