中国网站建设公司有哪些方面,凡科做的网站为什么搜不到,门户网站建设定做,微商城设计网站建设在.NET Core 上运行的 WordPress,无需安装PHP既可跨平台运行WordPress。 在Peachpie中实现PHP所需的功能数月后#xff0c;现在终于可以运行一个真实的应用程序#xff1a;WordPress。 本文是基于Peachpie https://github.com/iolevel/peachpie Peachpie是一个基于Microsof… 在.NET Core 上运行的 WordPress,无需安装PHP既可跨平台运行WordPress。 在Peachpie中实现PHP所需的功能数月后现在终于可以运行一个真实的应用程序WordPress。 本文是基于Peachpie https://github.com/iolevel/peachpie Peachpie是一个基于Microsoft的Roslyn的现代PHP编译器。 在.NET上运行WordPress 流行的Phalanger项目已经证明可以在Microsoft .NET上运行几乎未经修改的WordPress应用。 但是这个解决方案存在着问题与新的WordPress版本不兼容。现在Peachpie 也能够将WordPress作为一个完全托管的应用程序运行在.NET和.NET Core上。 这只是一个证明Peachpie仍然是一个正在进行中的项目。不建议在生产环境中使用它。 本篇文章主要目的是证明Peachpie真的与WordPress中使用的标准PHP兼容并展示其优点。 先决条件 .NET Core 1.0 MySQL Server 对WordPress修改 由于Peachpie 0.5.0版本编译器不支持扩展有条件声明的类如 if (condition) { class X {} }class Y extends X {} // extending conditionally declared class wp-includes/class-json.php 注释条件 if (!class_exists(...))注释第一个Services_JSON_Error类保留第二个 这里准备了一个修改好的WordPress版本已经包括上面修改使你编译项目更容易。 .NET Core WordPress 预先修改 wp-config.php 配置了包含MySQL数据库的凭据的文件。使用默认端口3306密码为 服务器是localhost。这里大家根据实际情况进行修改。 编译WordPress 编译由dotnet及其website/project.json 项目文件驱动。 { version: 1.0.0, buildOptions: { compilerName: php, compile: **\\*.php, debugType: portable, xmlDoc: true}, dependencies: { Peachpie.App: 0.5.0-*}, tools: { Peachpie.Compiler.Tools: 0.5.0-*}, frameworks: { netcoreapp1.0: { dependencies: { Microsoft.NETCore.App: { type: platform, version: 1.0.0}}}}
} 使用 Peachpie.Compiler.Tools 进行编译WordPress项目。 然后有一个app 项目也就是ASP.NET Core。 static void Main() { var root Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()) /website; var host new WebHostBuilder().UseKestrel().UseWebRoot(root).UseContentRoot(root) // content root with wp static files.UseUrls(http://*:5004/).UseStartupStartup() // initialization routine, see below.Build();host.Run();
}
class Startup { public void Configure(IApplicationBuilder app) {Pchp.Core.Context.DefaultErrorHandler new Pchp.Core.CustomErrorHandler(); // disables debug assertsapp.UsePhp(); // installs handler for *.php files and forwards them to our website.dllapp.UseDefaultFiles();app.UseStaticFiles();}
} 接着还原项目在根目录下dotnet restore. 还原好以后cd app dotnet run 然后访问http://localhost:5004/ ,只要MySQL 配置正确就会跳转至安装界面。注意要先在数据库中创建wordpress 数据库。 为了证明该网站真的在.NET Core上运行我们可以反编译website.dll 看看。 参考文档 https://github.com/linezero/peachpie-wordpress https://github.com/iolevel/peachpie-wordpress http://www.peachpie.io/2017/02/wordpress-announcement.html 原文地址http://www.cnblogs.com/linezero/p/6510115.html .NET社区新闻深度好文微信中搜索dotNET跨平台或扫描二维码关注