Hi,
I have created a bash script that will automatically setup sage for Windows users.
This has been tested with Windows 8.1 and the most recent version of Trellis as of 9/6/15.
This solves the lengthy process that must be completed after every ‘vagrant up’ or ‘vagrant destroy’
It completes many of the steps that I have described in the post below.
Soon I wll update this script to handle all of the file changes that must be handled on the VM in order to get the entire Trellis, Bedrock, Sage stack running.
But for now, this script will:
-
Creates node_modules folder & copies package.json from theme to
/srv/www/sitename.com on VM -
Installs nodejs & npm
-
Fixes permissions to run npm without sudo & get latest npm
-
Installs gulp and Bower globally
-
Creates a symlink between node_modules in theme folder and the one created on the VM by the script. NPM directories are not written back to the Window’s host machine in order to bypass Window’s 260 character file length limit.
-
Installs npm & bower locally in theme
-
Fixes hosts executable error which prevents deploys & provisions
Before you run this script, you will need to:
Enable symlinks between (L)ocal and (R)emote machines on 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
By default, VirtualBox disables symlinks for security reasons. So we need to add this
to our Vagrantfile.
config.vm.provider "virtualbox" do |vb|
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"]
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/current", "1"]
end
As of 8/5/15 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.
I’ve included
windows-sage.sh
Vagrantfile - For your reference
https://gist.github.com/darrienworth/05b68adf245e5fc7912a
If you see any errors while the script is running, try running it a second time.
Tips for speeding up Sage on the development server
In some cases the default shared folder implementations (such as VirtualBox shared folders) have high performance penalties. If you’re seeing less than ideal performance with synced folders, NFS can offer a solution. The bigger your project, the slower your development web server will run. I had 5-6++ second page load times before implementing this solution.
Contrary to the vagrant documentation, there is an NFS solution for Windows called winnfsd.
Install it with the following command in the cmd prompt.
$ vagrant plugin install vagrant-winnfsd
After your first ‘vagrant up’ and you have Trellis, Sage, Bedrock completely working and functional
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 web server a major performance boost!
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.
Please let me know if you have any issues.