作者 GitiJun 2017.01.14 09:53:59 写了58篇文章,回复33人, 在Ubuntu操作系统上安装mono和jexus搭建.NET的运行环境 阅读:1369· 评论:0· 喜欢:0 # 在Ubuntu操作系统上安装mono和jexus搭建.NET的运行环境 mono在国内的应用已经越来越多了。现在因为商业版权问题,很多公司都不敢将其用于生产环境上,但这无法挡住mono的魅力。.net的程序猿们,如果你还不知道mono那就太可惜了。 “Mono+Jexus”架构模式是Linux承载ASP.NET企业级应用的极为重要的架构方式。这种架构中,Jexus很好安装、配置,基本上就是一个下载、解压、复制的过程,但mono安装会麻烦点。 这篇文章将记录下在ubuntu操作系统下,使用Mono源码安装。后续安装jexus,并使用一个测试页面来验证jexus安装是否成功。jexus与mono的结合将在下一篇进行介绍。 摘自 [在Ubuntu操作系统上安装mono和jexus搭建.NET的运行环境 - 巴朗鱼 - 博客频道 - CSDN.NET](http://blog.csdn.net/ansencumt/article/details/9000436) ## 选择操作系统 因为整个过程运行于虚拟机,并且基于Linux发行版本选用问题,建议大家使用Ubuntu server版,我使用的版本是ubuntu server 12.04.2: ``` ansen@ansen:~$ cat /etc/issue Ubuntu 12.04.2 LTS \n \l ``` 如果你想升级ubuntu系统,可以运行以下两个命令: ``` sudo apt-get update sudo apt-get upgrade ``` 因为 ubuntu server在安装时,一般都会比较“干净”,所以我们还需要编译环境,这些编译环境,是顺利完成mono源码安装的必要条件: ``` sudo apt-get install build-essential sudo apt-get install automake autoconf sudo apt-get install bison gettext libtool libglib2.0-dev libfreetype6-dev libfontconfig-dev ``` 除了安装好这些编译环境外,在安装mono前,需要先安装Libgdiplus,而安装Libgdiplus前,又需要先安装以下的编译环境及库文件: ``` sudo apt-get install libgif-dev libtiff4-dev libpng12-dev libexif-dev libx11-dev libxft-dev libjpeg62-dev ``` 在运行上面的命令后,报了错: ``` ansen@ansen:~$ sudo apt-get install libgif-dev libtiff4-dev libpng12-dev libexif-dev libx11-dev libxft-dev libjpeg62-dev Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: libtiff4-dev : Depends: libjpeg-dev E: Unable to correct problems, you have held broken packages. ``` 错误信息也显示出来了,是因为libtiff4-dev需要依赖于libjpeg-dev而不是libjpeg62-dev,所以需要把命令最后一个参数改成libjpeg-dev: ``` sudo apt-get install libgif-dev libtiff4-dev libpng12-dev libexif-dev libx11-dev libxft-dev libjpeg-dev ``` 这样就运行成功了。 二、安装Libgdiplus 在前面的做准备工作做好后,其实后面就简单了,和使用源码安装其他应用程序一样的步骤。但在安装mono前记得一定要先安装Libgdiplus: ``` wget http://download.mono-project.com/sources/libgdiplus/libgdiplus-2.10.tar.bz2 ``` 最新版本可以在这边找到:Last modified 下载完成后,解压: ``` tar jvxf libgdiplus-2.10.tar.bz2 ``` 然后通过安装“三步曲”完成安装: ``` cd libgdiplus-2.10 ./configure --prefix=/usr make sudo make install cd .. ``` 补充:安装时出现错误 ``` gifcodec.c:927:2: error: too few arguments to function ‘EGifCloseFile’ EGifCloseFile (fp); ^ In file included from gifcodec.c:38:0: /usr/include/gif_lib.h:132:5: note: declared here int EGifCloseFile(GifFileType *GifFile, int *ErrorCode); ^ Makefile:468: recipe for target 'gifcodec.lo' failed make[2]: *** [gifcodec.lo] Error 1 make[2]: Leaving directory '/home/helloworld/libgdiplus-2.10/src' Makefile:320: recipe for target 'all-recursive' failed make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/home/helloworld/libgdiplus-2.10' Makefile:229: recipe for target 'all' failed make: *** [all] Error 2 ``` 按照网上操作仍旧出现此错误 三、安装mono 安装完Libgdiplus,就可以下载mono源码,并进行安装了,安装步骤和安装Libgdiplus基本一样: ``` wget http://download.mono-project.com/sources/mono/mono-3.0.10.tar.bz2 ``` mono最新版本可以在这边找到:Last modified 下载完成后,解压: ``` tar jvxf mono-3.0.10.tar.bz2 ``` 然后通过安装“三步曲”完成安装: ``` cd mono-3.0.10 ./configure --prefix=/usr make sudo make install cd .. ``` tar jvxf mono-3.4.0.tar.gz 四、mono另一种安装方法 虚拟机下的Linux有时候在安装mono时,在./configure这一步聚上,会出现gcc内部编译错误,这些错误很多时候是无头绪的。在这种情况下,可以使用以下方法来安装mono: 1、安装mono所需要的依赖程序 ``` sudo apt-get install build-essential bison gettext pkg-config autoconf libtool automake ``` 2、安装mono3.0 下载安装包,解压,并运行安装的sh文件: ``` wget http://download.mono-project.com/sources/mono/mono-3.0.10.tar.bz2 tar -xjvf mono-3.0.0.tar.bz2 cd mono-3.0.0 ./autogen.sh make sudo make install cd .. ``` 这里应该注意的一点是,./autogen.sh后面是可以带安装路径参数的,默认是安装路径是:/usr/local 安装成功后,查看mono的版本: 五、安装jexus 安装jexus比较简单,可到其官网下载:http://www.linuxdot.net/。下载链接位于官网右侧“重要下载”一栏中。咱们安装的是Jexus web server V5.3.1 正式版。安装命令如下: ``` wget http://www.linuxdot.net/down/jexus-5.3.1.tar.gz tar -zxv -f jexus-5.3.1.tar.gz ``` jexus-5.3.1文件夹,该文件夹下,有一个install,运行install解压后,进入 ``` cd jexus-5.3.1 ./install ``` 已经安装成功。 查看下jexus的默认配置,配置文件在/usr/jexus/siteconf/default: 配置中都有示例,还是相当好理解的,这里就不多说了。 下面我们新在/var/www/default下面新建一个index.html页面,页面包含一些简单的HTML代码,如下 : ``` Hello Jexus! Hello Jexus! ``` 然后回到/usr/jexus,运行如下命令: ``` ./jws start curl http://localhost/index.html ``` 可以看到,显示的结果如下图: 已经jexus服务已成功启动。 apt-get install bison apt-get install gettext apt-get install libtool apt-get install libglib2.0-dev apt-get install libfreetype6-dev apt-get install libfontconfig-dev apt-get install libgif-dev apt-get install libtiff5-dev apt-get install libpng12-dev apt-get install libexif-dev apt-get install libx11-dev apt-get install libxft-dev apt-get install libjpeg62-dev 赞 | 0 赏 标签:none