This is a quick starting guide to run "Hello, world" ASP.NET vNext app on mono/linux.
Installing mono 3.4.1
At first, you need to compile the latest mono version from sources. Sources are located at http://github.com/mono/mono. You can follow the docs on the main page, but BEWARE of using --prefix=/usr/local as option of autogen.sh file! Before doing it check where is your system mono installed. You can check it with which command.
$ which mono /usr/bin/mono
If mono is located in /usr/bin (for example Ubuntu holds it there) then you should change prefix to --prefix=/usr otherwise you'll get two different mono installation and could run into the issues "where is the proper library located?". If you use Ubuntu, you can run this script. It'll install mono, xsp (mono web server) and monodevelop IDE.
Installing ASP.NET vNext
Run the following commands:
wget https://raw.githubusercontent.com/graemechristie/Home/KvmShellImplementation/kvmsetup.sh chmod a+x kvmsetup.sh ./kvmsetup.sh source ~/.kre/kvm/kvm.sh kvm upgrade
Running "Hello, world!" application
git clone https://github.com/davidfowl/HelloWorldVNext cd HelloWorldVNext git submodule update --init kpm restore cd src/helloworldweb k web-firefly
It will start the web application at localhost:3001. To change host and port edit the file firefly/src/main/Firefly/ServerFactory.cs at line 30. Put there your host and port. No need to compile, just run k web-firefly again
You can also try to run Nowin host with the command k web, but due to the issue with sockets, you can run only ~1000 requests to your web server
I'm running 3.2.8 on Ubuntu 14.04 - I've noticed that mono -V outputs: "LLVM: supported, not enabled." compared to my local Mac "LLVM: yes(3.4svn-mono-(no/e656cac)" - would this update enable LLVM? Would that increase performance? Thanks.
ОтветитьУдалитьWhen I tried to use LLVM with Ubuntu half an year ago, I've got several issues with LLVM which made me think that LLVM does not work correctly on Ubuntu linux. What I saw on Ubuntu 12.04:
Удалить-No difference in performance, while running mono --with-llvm on simple tasks, like computing string hashes.
-Less performance, while running xsp web server --with-llvm.
-mono can't use profiler if compiled with LLVM. https://bugzilla.xamarin.com/show_bug.cgi?id=16785
But this is for Ubuntu. Xamarin developers say, that under Mac LLVM works as expected. They say it provides ~20% speed boost for computing string hashes and profiler works too. I don't have a Mac, so I can't check performance for running web server with llvm enabled options and see the difference.
By the way if you want to run ASP.NET vNext, you must compile and install Mono 3.4.1. Also, I can point you to my HyperFastCgi web server http://github.com/xplicit/HyperFastCgi if you want to host web applications on linux behind nginx. It works faster than mono-server-fastcgi and does not leak memory as last.