We’ve begun running Mono on some Bit Badger Solutions servers to enable us to support the .NET environment, in addition to the PHP environment most of our other applications use. While Ubuntu has nice packages (and Badgerports even
brings brought them up to the latest release), one thing that we were missing was a “conf.d”-type of configuration; my “/applications=” clause of the command was getting really, really long. We decided to see if we could create something similar to Apache / Nginx’s sites-available/sites-enabled paradigm, and we have succeeded!
To begin, you’ll need to create the directories
/etc/mono/fcgi/apps-enabled. These directories will hold files that will be used define applications. The intent of these directories is to put the actual files in
apps-available, then symlink the ones that are enabled from
apps-enabled. These files have no name restrictions, but do not put an extra newline character in them. The script will concatenate the contents of that file to create the MONO_FCGI_APPLICATIONS environment variable, which tells the server what applications exist. (The syntax is the same as that for the “/applications=” clause -
[domain]:[URL path]:[filesystem path].) Here’s how the site you’re reading now is configured (from the file
Finally, what brings it all together is a shell script. This should be named “monoserve” and placed in
/etc/init.d. (This borrows heavily from
this script a script we found online, which we used until we wrote this one.) Note the group of variables surrounded by the “make changes here” notes - these are the values that are used in starting the server. They are at the top so that you can easily modify this for your own needs.
This needs to be owned by root and be executable (
chmod +x monoserve). You can use
update-rc.d monoserve defaults to set this to start at boot.