Skip to content

chilimangoes/vagrant-mono-nginx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vagrant-Mono-Nginx

This project contains everything necessary to set up a Vagrant box running an ASP.NET web server on Ubuntu, using Mono, Nginx and FastCGI Mono. It uses a package generated by the vagrant-mono repository as a base box.

Important note: The ./build-support/server-files/init.d/monoserve file needs to have Unix-style line endings, otherwise you will get a cryptic : File does not exist error when trying to start up the FastCGI Mono server. If you're running Windows and have GIT configured to automatically manage text file line endings (their default recommended setting on Windows), GIT will change the line endings on this file to Windows-style CR/LF when you clone the repository, resulting in the aforementioned error when the file is copied to your Vagrant box running Linux. I personally find this setting to be more trouble than it's worth and prefer to manage my own line endings because any reasonably good IDE or text editor understands Unix-style line endings. To turn off this setting, run the follwing command from the command prompt (eg, by running GIT Bash if you have GIT for Windows installed).

	git config --global core.autocrlf false

Prerequisites:

  1. Install VirtualBox - NOTE: If you are running on Windows 8 please make sure not to install the network drivers, as explained in this post: http://www.grumpydev.com/2013/06/19/windows-8-hyper-v-virtualbox-vagrant-and-hanging-on-boot/
  2. Install Vagrant from http://www.vagrantup.com/
  3. Install the vagrant-mountcommand plugin for Vagrant by running vagrant plugin install vagrant-mountcommand. This is to work around a current limitation with running commands at boot time that need to run after Vagrant mounts the /vagrant shared folder. See here for more details.

How to use this Vagrant box:

Build it yourself

Once you have the prerquisites installed and have built and installed the vagrant-mono base box, do the following:

	git clone git://github.com/chilimangoes/vagrant-mono-nginx.git
	cd vagrant-mono-nginx
	vagrant up

Provisioning your new development server will take a few minutes. When it's done, you will need to restart the server by issuing a vagrant reload command. When your box comes back up, your development server will be ready. You can run vagrant ssh to connect to the box and start using it.

Hosting a Web Project

If you navigate to http://localhost:8093/Default.aspx you should see a test page.

Out of the box, the ./src/WebProject directory in this repository will be mounted as /var/wwwroot on the server. When you add/remove/edit files in this directory, your changes will be reflected at the URL above. If you change the name of this folder from WebProject to something else, you will need to edit the $WEB_PROJECT_FOLDER variable in the Vagrantfile.

Note: Shared folders in VirtualBox have a bug where files that are modified on the host system do not trigger file system events in the guest, and vice-versa. Because Nginx and FastCGI Mono listen for these events to trigger updating resources, recompiling ASPX pages, reloading DLLs, etc, this causes changes made locally to not show up unless the web server is restarted. To work around this issue, a script is installed which monitors /var/wwwroot for changes and issues a touch /var/wwwroot command to trigger a file system event that Nginx and FastCGI Mono can pick up. By default, this script (./build-support/server-files/development/wwwroot-watcher.sh) is set to rescan for changes every 5 seconds. This value can be adjusted based on your project size to balance responsiveness to changes with the performance impact that scanning for changes might have on a large directory tree.

Reference:

The Vagrantfile and setup scripts used here are based on code and examples from various locations:

About

Vagrant box running an ASP.NET web server under Mono on Ubuntu

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published