2017-03-07 74 views
1

我設法讓Azure WebApp上的Imagick工作,遵循@Saurabh Kumar手冊http://techblog.saurabhkumar.com/2015/12/setting-up-imagemagick-for-php-on-azure.html(取而代之的是php7的相關包),但是一旦我在同一個App上啓用Composer擴展,Azure爲imagick放棄PATH。配置啓用Composer的Azure WebApp上的Imagick

There is a comment on MS blog建議編輯Composer applicationHost.xdt,而不是爲Imagick創建新的applicationHost.xdt文件(如果安裝了Composer)。 我已經嘗試過,但它擊碎了整個應用程序(HTTP錯誤503)。

有沒有辦法讓Imagick和Composer都能在Azure WebApp上工作?

回答

1

我在你身邊轉載了你的問題。經過一番調查後,我找到了一種讓Imagick和Composer都能在Azure WebApp上工作的方法。我知道它並不漂亮,但它確實有效。

1)使用FTP或SCM(websitename.SCM.azurewebsites.net)進入D:\home\SiteExtensions\ComposerExtension fodler,並刪除applicationHost.xdt文件。

2)合併上面刪除的文件的內容到D:\home\site\applicationHost.xdt。在此之後,xdt文件應該是這個樣子:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 
    <system.applicationHost> 
    <sites> 
     <site name="%XDT_SCMSITENAME%" xdt:Locator="Match(name)"> 
     <application path="/Composer" applicationPool="%XDT_APPPOOLNAME%" xdt:Transform="Insert"> 
      <virtualDirectory path="/" physicalPath="%XDT_EXTENSIONPATH%" /> 
     </application> 
     </site> 
    </sites> 
    </system.applicationHost> 
    <system.webServer> 
    <runtime xdt:Transform="InsertIfMissing"> 
     <environmentVariables xdt:Transform="InsertIfMissing"> 
     <add name="MAGICK_HOME" value="d:\home\site\ext\" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" /> 
     <add name="MAGICK_CODER_MODULE_PATH" value="d:\home\site\imagickwin\" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" /> 
     <add name="APPSETTING_COMMAND" value="%HOME%\SiteExtensions\ComposerExtension\Hooks\deploy.cmd" /> 
     <add name="COMPOSER_ARGS" value="--prefer-dist --no-dev --optimize-autoloader --no-progress" /> 
     <add name="PATH" value="%PATH%;%PATH%d:\home\site\ext\;%HOME%\SiteExtensions\ComposerExtension\Commands;%APPDATA%\Composer\vendor\bin" /> 
     </environmentVariables> 
    </runtime> 
    <rewrite xdt:Transform="InsertIfMissing"> 
     <rules xdt:Transform="InsertIfMissing"> 
     <rule name="RequestBlockingRule1" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" stopProcessing="true"> 
      <match url=".*" /> 
      <conditions> 
       <add input="{URL}" pattern="vendor/(.*)$" /> 
      </conditions> 
      <action type="CustomResponse" statusCode="403" statusReason="Forbidden: Access is denied." statusDescription="You do not have permission to view this directory or page using the credentials that you supplied." /> 
     </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
</configuration> 

3)現在,重新啓動您的應用程序,他們應該共同努力。

enter image description here

enter image description here

+0

謝謝你,它的工作這一次!不知道爲什麼它沒有工作之前,我想我可能會添加一些錯誤的論點,導致PHP的一般錯誤。我希望微軟有更優雅的解決方案,並希望稍後它不會引起Imagick的問題。 – gibengy