微軟的Windows Azure上也支持Linux虛擬機服務,下面我使用Azure的虛擬機服務跑一個OpenSuse的虛擬機測試Mono 3.0.2, 測試ASP.NET WebAPI 失敗了。
安裝系統補丁和更新:
azureuser@mono3:/usr/src/local> sudo zypper update
安裝Wget工具包
azureuser@mono3:/usr/src/local> sudo zypper install wget
看下系統的版本是x86_64,下載相應版本的Mono 3.0.2安裝包:
azureuser@mono3:/usr/src/local> sudo uname -a
Linux mono3 3.1.10-1.10-default #1 SMP Mon May 28 14:19:15 UTC 2012 (94036a4) x86_64 x86_64 x86_64 GNU/Linux
wget默認會根據網站的robots.txt進行操作,如果robots.txt里是User-agent: * Disallow: /的話,wget是做不了鏡像或者下載目錄的,使用-e robots=off參數即可繞過該限制。
指定下載制定后綴的文件,如只下載http://download.mono-project.com/archive/3.0.2/linux/x64/下.rpm文件:
azureuser@mono3:/usr/src/local> sudo wget -nd -r -l1 --no-parent -e robots=off -A.rpm http://download.mono-project.com/archive/3.0.2/linux/x64/
確認已經完全下載成功了Mono軟件包
azureuser@mono3:/usr/src/local> ls
ibm-data-db2-3.0.2-0.x86_64.rpm mono-data-sqlite-3.0.2-0.x86_64.rpm
libmono-2_0-1-3.0.2-0.x86_64.rpm mono-devel-3.0.2-0.x86_64.rpm
libmono-2_0-devel-3.0.2-0.x86_64.rpm monodoc-core-3.0.2-0.x86_64.rpm
libmonosgen-2_0-0-3.0.2-0.x86_64.rpm mono-extras-3.0.2-0.x86_64.rpm
libmonosgen-2_0-devel-3.0.2-0.x86_64.rpm mono-locale-extras-3.0.2-0.x86_64.rpm
mono-complete-3.0.2-0.x86_64.rpm mono-mvc-3.0.2-0.x86_64.rpm
mono-core-3.0.2-0.src.rpm mono-nunit-3.0.2-0.x86_64.rpm
mono-core-3.0.2-0.x86_64.rpm mono-wcf-3.0.2-0.x86_64.rpm
mono-data-3.0.2-0.x86_64.rpm mono-web-3.0.2-0.x86_64.rpm
mono-data-oracle-3.0.2-0.x86_64.rpm mono-winforms-3.0.2-0.x86_64.rpm
mono-data-postgresql-3.0.2-0.x86_64.rpm mono-winfxcore-3.0.2-0.x86_64.rpm
安裝下載的所有Mono軟件包
azureuser@mono3:/usr/src/local>sudo zypper install *.rpm
查看成功安裝了mono 3.0.2
azureuser@mono3:/usr/src/local> mono --version
Mono JIT compiler version 3.0.2 (tarball Wed Dec 5 14:50:07 GMT 2012)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)
安裝Jexus 5.2
azureuser@mono3:/usr/src/local> sudo wget http://linuxdot.net/down/jexus-5.2.tar
azureuser@mono3:/usr/src/local> sudo tar -zxvf jexus-5.2.tar.gz
具體可以參照 32和64位的CentOS 6.0下 安裝 Mono 2.10.8 和Jexus 5.0
然后放了一個ASP.NET Web API項目(http://code.msdn.microsoft.com/wpapps/Contact-Manager-Web-API-0e8e373d)上去測試了下,WebAPI項目還是跑不起來,繼續測試下個版本,可以訪問這個地址看到具體錯誤 http://ndon.cloudapp.net/default.htm。也有同學在報這個問題 http://mono.1490590.n4.nabble.com/ASP-NET-Web-API-on-Mono-3-0-Could-not-load-type-System-Web-Http-WebHost-HttpControllerHandler-td4657079.html , 后來在Mono 3.0.4上成功了。
參考文檔:
Create a Virtual Machine Running Linux
Use root privileges on Linux virtual machines in Windows Azure