在启用 Composer 的情况下在 Azure WebApp 上配置 Imagick
Configuring Imagick on Azure WebApp with Composer enabled
按照@Saurabh Kumar 手册 http://techblog.saurabhkumar.com/2015/12/setting-up-imagemagick-for-php-on-azure.html(已替换为 php7 的相关包),我已经设法让 Imagick 在 Azure WebApp 上工作,但是一旦我在同一个应用程序上启用 Composer 扩展, Azure 正在失去 imagick 的路径。
There is a comment on MS blog 建议编辑 Composer applicationHost.xdt 而不是为 Imagick 创建新的 applicationHost.xdt 文件,如果安装了 Composer。
我试过了,但它破坏了整个应用程序(HTTP 错误 503)。
有没有办法让 Imagick 和 Composer 在 Azure WebApp 上工作?
我在我这边重现了你的问题。经过一些调查,我找到了一种让 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) 现在,重新启动您的应用程序,它们应该可以协同工作。
按照@Saurabh Kumar 手册 http://techblog.saurabhkumar.com/2015/12/setting-up-imagemagick-for-php-on-azure.html(已替换为 php7 的相关包),我已经设法让 Imagick 在 Azure WebApp 上工作,但是一旦我在同一个应用程序上启用 Composer 扩展, Azure 正在失去 imagick 的路径。
There is a comment on MS blog 建议编辑 Composer applicationHost.xdt 而不是为 Imagick 创建新的 applicationHost.xdt 文件,如果安装了 Composer。 我试过了,但它破坏了整个应用程序(HTTP 错误 503)。
有没有办法让 Imagick 和 Composer 在 Azure WebApp 上工作?
我在我这边重现了你的问题。经过一些调查,我找到了一种让 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) 现在,重新启动您的应用程序,它们应该可以协同工作。