- 在Centos7上安装Mono
yum install yum-utils
rpm --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"
yum-config-manager --add-repo http://download.mono-project.com/repo/centos/
yum install mono-devel
yum insall mono-complete
- 下载Jexus,下载地址htttp://www.linuxdot.net/
- 安装Jexus
tar -zxvf jexus-5.8.0.tar.gz
cd jexus-5.8.0
sudo ./install
默认安装路径为/usr/jexus - 启动Jexus
cd /usr/jexus
sudo ./jws start然后在浏览器中输入localhost/info
会显示如下界面 - 要想在Jexus上运行,还要在项目中添加一个Adapter和RazorConfig类,代码如下,只需要原样复制项目中即可
-
using System; using System.Collections.Generic; using Microsoft.Owin.Builder; using System.Threading; using System.Threading.Tasks;namespace WebSite {/// <summary>/// Jexus/TinyFox OWIN适配器/// </summary>class Adapter{/************************************** 这是一个比较完整的适配器示例* ***********************************//// <summary>/// OWIN 应用程序委托/// </summary>static Func<IDictionary<string, object>, Task> _owinApp;/// <summary>/// 适配器构造函数/// </summary>public Adapter(){//实例化一个应用程序生成器var builder = new AppBuilder();// 为生成器添加一些参数// 因某些OWIN框架需要从该参数中得到一些初始化环境信息// 这些信息可以包括 如“owin版本”“服务器功”能等等var properties = builder.Properties;properties["owin.Version"] = "1.0"; // 只能是1.0var disposeSource = new CancellationTokenSource();properties["server.OnDispose"] = disposeSource.Token;Func<Task> svrInitCallback = null;Action<Func<Task>> init = (callback) => { svrInitCallback = callback; };properties["server.OnInit"] = init;//.......var capabilities = properties.ContainsKey("server.Capabilities") ? properties["server.Capabilities"] as IDictionary<string, object> : new Dictionary<string, object>();properties["server.Capabilities"] = capabilities;capabilities["server.Name"] = "TinyFox";//capabilities["websocket.Version"] = "1.0";//......//实例化用户的启动类,并调用配置方法//如果用户启动类在其它的dll中,就需要通过反射找出这个类var startup = new Startup();startup.Configuration(builder);//构建OWIN应用并获取该应用的代理(委托)方法_owinApp = builder.Build();//要求应用程序域退出时,向本类发出通知AppDomain.CurrentDomain.DomainUnload += ((o, e) => { disposeSource.Cancel(); });//回调应用层初始化函数if (svrInitCallback != null) svrInitCallback().Wait();}/// <summary>/// *** Jexus/TinyFox所需要的关键函数 ***/// </summary>/// <param name="env">新请求的环境字典,具体内容参见OWIN标准</param>/// <returns>返回一个正在运行或已经完成的任务</returns>public Task OwinMain(IDictionary<string, object> env){//如果为空if (_owinApp == null) return null;//调用Microsoft.Owin的应用程序委托函数,将请求传给OWIN框架return _owinApp(env);}} }
using System; using System.Collections.Generic; using Nancy; using Nancy.ViewEngines.Razor;namespace WebSite {public class RazorConfig : IRazorConfiguration{public bool AutoIncludeModelNamespace{get{return true;}}public IEnumerable<string> GetAssemblyNames(){yield return "System.Web.Razor";}public IEnumerable<string> GetDefaultNamespaces(){yield return "System.Web.Razor";}} }
- 发布站点到本地,用WinSCP连接服务器,将发布后的文件拷贝到Linux服务器上的/var/www/website目录下.然后切换到/usr/jexus/siteconf目录,新建一个文件,名称为website,将目录下default文件的内容复制过来,并修改配置
port=91
root=/ /var/www/website
hosts=* #OR your.com,*.your.com
owinmain=WebSite.dll - 修改防火墙
$ vi /etc/sysconfig/iptables
$ i,添加端口
-A INPUT -p tcp -m tcp --dport 91 -j ACCEPT
$ esc
$ :wq保存退出
$ service iptables restart -
重新jexus
cd /usr/jexus/
sudo ./jws restart
输入localhost:91/
转载于:https://www.cnblogs.com/lpush/p/5164708.html