在Ubuntu中搭建.NET开发环境

Mono简介
Mono是Xamarin公司C#和CLR的ECMA标准基于开发的一个开源的.NET实现版本,它是Linux平台上开发.NET应用程序首选。同时其也提供了Xamarin.IOS和Xamarin.Andriod,是我们可以直接使用C#开发IOS和Andriod手机开发。
安装Mono
Mono的乌班图版本是由社区提供维护的。以下的版本在标准的Ubuntu库中是可用的:
Ubuntu Hardy (8.04 LTS):     1.2.6
Ubuntu Lucid (10.04 LTS):     2.4 branch snapshot
Ubuntu Natty (11.04):     2.6.7
Ubuntu Oneiric (11.10):     2.10.5
Ubuntu Precise (12.04 LTS):     2.10.8.1
Ubuntu Quantal (12.10):     2.10.8.1
Ubuntu默认安装的应用程序例如Tomboy、F-Spot等是需要使用Mono的,所以在12.04以前的发布版本中就已经默认安装了Mono。在12.04和以后的版本,我们可以使用mono-complete来安装Mono的全部组件。安装完成使用mono --version查看Mono相关信息。

验证Mono是否安装成功
1. 打开gedit并将如下代码保存为helloworld.cs文件

using System;
 
public class HelloWorld
{
    static public void Main ()
    {
        Console.WriteLine ("Hello Mono World");
    }
 
}

 


2. 使用mcs helloworld.cs编译,完成后使用mono helloworld.exe执行生成的可执行文件。

安装mono-fastcgi-server2
sudo apt-get install mono-fastcgi-server2

安装Nginx
1.输入以下命令安装Nginx,sudo apt-get install nginx

2. 打开以下配置文件 /etc/nginx/sites-available/default,并添加如下内容

server {
         listen   30000;
         server_name  localhost;
         access_log   /var/log/nginx/mono.log;
 
         location / {
                 #root /usr/share/nginx/www;
         root /home/hys/Mono/sites/mysite;
                 index index.html index.htm default.aspx Default.aspx;
                 fastcgi_index Default.aspx;
                 fastcgi_pass 127.0.0.1:9000;
                 include /etc/nginx/fastcgi_params;
         }
 }

 


3. 打开配置文件/etc/nginx/fastcgi_params,并添加如下内容

 fastcgi_param  PATH_INFO          "";
 fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

 


4. 在终端中执行如下命令启动FastCgi服务器
fastcgi-mono-server2 /applications=*:30000:/:/home/hys/Mono/sites/mysite /socket=tcp:127.0.0.1:9000
5. 启动Nignx服务器
 /etc/init.d/nginx start

安装monoDevelop集成开发工具
sudo apt-get install monodevelop

posted @ 2014-07-05 18:46  无风听海  阅读(14346)  评论(25编辑  收藏  举报