liyeho 发表于 2017-6-23 11:01:49

Mono+Jexus让C#运行在Linux(centos7_x64),学习笔记

本篇目录


[*]  前言

[*]  环境准备

[*]  Linux下环境准备

[*]  系统更新

[*]  安装Mono源码安装需要的库

[*]  安装Mono需要的GDI+兼容API的库Libgdiplus

[*]  安装 mono

[*]  Jexus安装





[*]  部署ASP.NET MVC项目

[*]  Jexus配置

[*]  VS2013创建MVC项目打包发布



[*]  总结


前言
  感谢:
  http://www.jexus.org/
  http://www.cnblogs.com/shanyou/archive/2012/01/07/2315982.html
  http://www.cnblogs.com/hanyinglong/p/5456757.html
  http://www.iyunv.net/article/83550.htm
  http://www.cnblogs.com/hanyinglong/p/5456757.html
  http://bbs.csdn.net/topics/390944302

环境准备
  虚拟机:VMware-workstation-full-11.0.0-2305329_0;
  Linux系统:CentOS-7-x86_64-DVD-1511.iso;
  Visual Studio 2013:创建默认ASP.NET MVC 4 Web 应用程序;
  Linux连接工具:SecureCRT;

Linux下环境准备

更新系统
  可以跳过,有四百多条更新。
  yum –y update

安装Mono源码安装需要的库
  yum -y install gcc gcc-c++ bison pkgconfig glib2-devel gettext make libpng-devel libjpeg-devel libtiff-devel libexif-devel giflib-devel libX11-devel freetype-devel fontconfig-develcairo-devel


安装Mono需要的GDI+兼容API的库Libgdiplus
  cd /usr/local/src/


  libgdiplus下载地址,当前最新版本libgdiplus-4.2.tar.gz | 2015-12-20 17:33 | 671K
  wget http://download.mono-project.com/sources/libgdiplus/libgdiplus-4.2.tar.gz
  tar -zxvf libgdiplus-4.2.tar.gz
  cd libgdiplus-4.2
  ./configure --prefix=/usr
  make && make install

安装 mono
  cd /usr/local/src/
  mono下载地址,当前最新版本mono-4.6.2.6.tar.bz2 | 2016-11-02 14:22 | 79M
  wget http://download.mono-project.com/sources/mono/mono-4.6.2.6.tar.bz2
  tar -jxvf mono-4.6.2.6.tar.bz2

  cd mono-4.6.2
  ./configure --prefix=/usr
  make这步的时间稍微比较久点。
  make && make install
  安装完后使用mono -V查看版本信息。


Jexus安装
  cd /usr/local/src/
  Jexus下载地址,当前最新版本jexus-5.8.1.tar.gz
  wget http://www.linuxdot.net/down/jexus-5.8.1.tar.gz
  tar -zxvf jexus-5.8.1.tar.gz
  cd jexus-5.8.1
  ./install

  启动命令。
  /usr/jexus/jws start



  启动成功后通过http://localhost/info访问到如下页面。

  至此环境准备工作完成。

部署ASP.NET MVC项目

Jexus配置
  cd /usr/jexus/siteconf/
  cp default simple
  赋值默认配置修改port、root。

  配置修改完成后到/var目录下创建www文件夹。
  cd /var
  mkdir www

VS2013创建MVC项目打包发布
  使用SecureFX将打包文件夹simple上传至/var/www/simple目录。

  将jexus停止后重新启动
  /usr/jexus/jws stop


  /usr/jexus/jws start
  启动成功后通过http://localhost/info访问出现如下错误信息。

  将Web.config文件内容替换成如下信息重新上传。



<?xml version="1.0" encoding="utf-8"?>
<!--
有关如何配置 ASP.NET 应用程序的详细信息,请访问
http://go.microsoft.com/fwlink/?LinkId=169433
-->

<configuration>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>

<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>

<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>

</assemblyBinding>
</runtime>
<system.web>
<customErrors mode="Off"/>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers></system.webServer>
</configuration>
  /usr/jexus/jws restart
  log4net引用到项目中。
  重新启动后刷新能访问显示如下,但是样式信息未应用。这是因为Linux下是区分大小写的,需要配置jexus。

  cd /usr/jexus/
  vi jws
  取消# export MONO_IOMAP="all"这段内容的前面的#,保存,然后重新启动jexus。

  重启jws后,重新访问结果。


总结
  没写完。
页: [1]
查看完整版本: Mono+Jexus让C#运行在Linux(centos7_x64),学习笔记