Running WordPress on .NET Core

About year ago I wrote a blog post Running PHP applications on .NET Core where I introduced how to build PHP applications to .NET Core using Peachpie. Their showcase was WordPress – the famous blog engine that also runs my blog. Peachpie guys have made significant work over year and they have reached the point where whole WordPress is built as .NET Core application.

WordPress built to .NET Core using Peachpie

Why WordPress on .NET Core?

As experienced blogger on WordPress I see some use cases for WordPress on .NET Core.

  • Security. As all WordPress code is compiled to DLL and considering how ASP.NET Core applications are deployed to Azure there will be no scripts available for direct requests. Better yet – all code one can run is located out from wwwroot.
  • Performance. Benchmarks by Peachpie guys show a little performance for WordPress on .NET Core. I see there two opportunities for performance raise: optimizations by Microsoft to .NET Core and ASP.NET Core and optimizations by Peachpie guys.
  • No need for PHP on server. I don’t need to run PHP on live environment as compiled WordPress runs 100% on .NET Core as ASP.NET Core web application.

Setting WordPress on .NET Core up

  1. Set up MySQL on your dev box. It must listen to default port (3306). You must have user “root” with password “password”
  2. Install .NET Core SDK 2.1.3
  3. Clone code from GitHub repository iolevel/wpdotnet-sdk using URL
  4. Open command prompt and move to folder where you cloned repository
  5. Build solution using command dotnet build (ignore all warnings)
  6. Run solution using command dotnet run -p app
  7. Open browser and navigate to http://localhost:5004

You should see now first page of WordPress installation.

What to try?

There are multiple things to try out specially when you are plugin or theme developer. Here are some ideas in random order:

  • How well WordPress on .NET Core performs for you
  • Is my theme compatible with WordPress on .NET Core
  • Is my plugin compatible with WordPress on .NET Core
  • Is everything working like expected
  • How to build WordPress plugins in C#

NB! After adding new plugin or applying new theme it is recommended to build WordPress again. Some plugins and themes are not compatible with WordPress on .NET Core – you will see PHP code fragments in browser window in this case.

Wrapping up

Having WordPress running on .NET Core one day as a stable and performant ASP.NET Core web application will be huge. Specially when it’s compatible also with Azure App Service. I think Peachpie and Microsoft together can reach to the point where WordPress is 100% Azure cloud ready and really considerable option for serious bloggers whose blogs face growing visitor numbers.

NB! Not all WordPress plugins and themes are not fully working yet and activating them make things awkward. Fragments of plugins and themes code are shown on screen after activating them. Vanilla WordPress with no plugins activated works fine. There is one mandatory plugin that must stay activated: Peachpie API.

If you plan to try out things like experimenting with PHP or write WordPress plugins in C# (yes, it’s possible now) then I suggest you to go with Visual Studio Code. Visual Studio is able to open the project after building it first on command line using dotnet tool but it wasn’t able to run the application. You can use dotnet build and dotnet run commands on command line to build and run application after modifications.

Gunnar Peipman

Gunnar Peipman is ASP.NET, Azure and SharePoint fan, Estonian Microsoft user group leader, blogger, conference speaker, teacher, and tech maniac. Since 2008 he is Microsoft MVP specialized on ASP.NET.

    Leave a Reply

    Your email address will not be published. Required fields are marked *