1

Short: I'm trying to get PHP to run in the same site as an ASP.Net Core site.

Long: I've re-written my web-site to migrate from an WebForms site an ASP.Net core 1.1 site. My old site ran both ASP.NET and PHP together (I had an instance of WordPress running under a sub-folder that was used to write blog posts into a sqlite database, essentially using it as a content management piece and it's worked well for that for 4 years).

I had hoped to do the same thing with ASP.Net Core on Azure but am running into issues. I've published the site and the .Net side fires up and runs. The PHP no longer works however (it seems like those files maybe routing through ASP.Net Core?..

In Azure I'm using the .Net Framework 4.6 and PHP 5.6. "index.php" is setup as one of the default documents. I have tried setting up handler mappings to the php-cgi.exe. I found the following in the EventLog which makes me think the files aren't being routed to PHP:

<Event> <System> <Provider Name="IIS AspNetCore Module"/> <EventID>1000</EventID> <Level>0</Level> <Task>0</Task> <Keywords>Keywords</Keywords> <TimeCreated SystemTime="2017-06-05T18:36:25Z"/> <EventRecordID>426103812</EventRecordID> <Channel>Application</Channel> <Computer>RD0003FF4207D0</Computer> <Security/> </System> <EventData> <Data>Application 'MACHINE/WEBROOT/APPHOST/YOURSITE/BLOG' with physical root 'D:\home\site\wordpress\' failed to start process with commandline '".\yoursite.exe" ', ErrorCode = '0x80070002 : 0.</Data> </EventData> </Event>

Notes:

  • I attempted to pull the WordPress files out of the published content and make it a virtual directory (this resulted in a HTTP Error 502.5 Process Failure when PHP content would be referenced).
  • I left the WordPress files as a sub folder in my ASP.Net Core site and re-published, these seem to route through ASP.Net Core (and take me to a 404 when PHP pages are accessed.. although the static files in that folder reference fine).

What do I need to do to run ASP.Net Core and PHP in the same site?

b.pell
  • 3,873
  • 2
  • 28
  • 39

2 Answers2

4

Managed to resolve by doing the following.

Adding a web.config in the /blog directory, to remove the aspNetCore handler

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>    
    <handlers>
      <remove name="aspNetCore"/>
    </handlers>
  </system.webServer>
</configuration>
1

I'm not an ASP.Net Core expert but I believe that virtual directory is the best choice to achieve your requirement. You can check out the following threads for details.

How can I host a php script on a dotnet core web app hosted at Azure

Create virtual directory on same azure web app

Aaron Chen
  • 9,835
  • 1
  • 16
  • 28
  • Thank you for the response. I tried both of these to no avail. I tried the publishing the PHP straight into the virtual folder as shown (and that published fine) but I still get the "HTTP Error 502.5 - Process Failure" when the virtual directory is called from a web-browser. – b.pell Jun 06 '17 at 16:15