Change document root on azure php webrole

2019-08-14 04:44发布

问题:

I want setup Laravel framework on azure webrole and have to change document root, but so far I can't find way how to do this

My deployment project folder:

├──webrole <- now this is document root
│  ├──app
│  ├──bin
│  ├──bootstrap
│  ├──config
│  ├──database
│  ├──public <- I want make this as document root
│  ├──resources
│  ├──storage
│  ├──tests
│  ├──vendor
│  ├──.env
│  ├──.env.example
│  ├──.gitattributes
│  ├──.gitignore
│  ├──artisan
│  ├──composer.json
│  ├──composer.lock
│  ├──gulpfile.js
│  ├──package.json
│  ├──phpspec.yml
│  ├──phpunit.xml
│  ├──readme.md
│  ├──server.php
│  ├──Web.cloud.config
│  └──Web.config
├──deploymentSettings.json
├──ServiceConfiguration.Cloud.cscfg
├──ServiceConfiguration.Local.cscfg
├──ServiceDefinition.csdef

I found this Change approot path of Windows Azure WebRole but it's quite old question and there isn't approved answer

The only one workaround I've found is using rewrite rules but, I think that is not secure...

回答1:

As in Azure Cloud Service PHP WebRole directory, where are web.config and web.cloud.config files which is leveraged to configure PHP site application on IIS.

Web can find the content like the following in these files:

<system.webServer>
    <defaultDocument>
      <files>
        <clear />
        <add value="index.php" />
      </files>
    </defaultDocument>
  </system.webServer>

We can modify the setting defaultDocument to change the document root of your laravel application:

<system.webServer>
    <defaultDocument>
      <files>
        <clear />
        <add value="public/index.php" />
      </files>
    </defaultDocument>
  </system.webServer>