This post will not cover advanced topics, such as setting up an SSL certificate or linking with a database. It will just get the barebones ASP.NET server deployed. Note, however, that there are better ways to deploy an ASP.NET MVC service than what this post describes (through fastcgi or mod_mono), so if you're concerned about the RIGHT way of doing things rather than the FAST way of doing things, follow that link.
Structure - Skip if you have a project
Let's make ourselves an ASP.NET MVC application in Monodevelop. If you don't already have monodevelop, you'll need to install the following packages:
this should create an ASP.NET MVC project that's ready for deploying.
Now, it's time to compile the project. This is where a program from mono-devel comes into play. xbuild, an implementation of msbuild (link) is what will generate what the web server runs. The binaries are generated from the .sln or .csproj file itself.
So, open up a terminal and go to the project root, where your project file is.
Then issue the "xbuild" command on your file. This will build all targets for the project, which are Debug and Release by default in Monodevelop
Wonderful! If everything in your project passes, you have successfully built your ASP.NET MVC application
Now, here are where the tough decisions are made. If you are truly deploying a production service, you should do the following things:
- Secure a webserver, preferably a dedicated virtual machine
- Generate SSL certificates / other cryptographic keys
- Create a user for running your service
- Install the fastcgi-mono or mod_mono (apache) modules and run your service from Apache
However, the quick-n'-dirty way I do it is with xsp4. xsp is yet another pet project of Mono's, that aims to be a fast ASP.NET web server for development. However, there is nothing that says you can't use it in production. It allows SSL certificates, variable ports, etc. so you won't find yourself missing too many features from Apache.
Running xsp4 is dead simple. Go to the build directory (the one under your project root) and run "
xsp4 --port 80"
if all goes well with this, you should have a full-fledged ASP.NET MVC 4 application deployed under Linux, and available on the standard http port. This is, of course, the unsecure, bare-bones deployment with xsp4. But it's a good starting point. To find out how to make xsp4 handle errors, set up your certificates, etc. issue the command
Hope you found this useful!