php - Azure 网站 PHP API - 不允许使用 500 方法

标签 php api azure

我刚刚在本地服务器上完成了 PHP API,它运行得很好。现在我尝试将其部署在 Azure Web App 上,但在任何 get/post 请求期间收到错误,例如: enter image description here

这是我的 web.config 文件:

<configuration>
    <location>
        <system.webServer>
            <security>
                <authentication>
                    <anonymousAuthentication enabled="true" />
                    <iisClientCertificateMappingAuthentication enabled="true" oneToOneCertificateMappingsEnabled="true" manyToOneCertificateMappingsEnabled="false" logonMethod="ClearText">
                        <oneToOneMappings>
                            <clear />
                            <add userName="domain\user" password="pass" certificate="the certificate blob" />
                        </oneToOneMappings>
                        <manyToOneMappings>
                            <clear />
                        </manyToOneMappings>
                    </iisClientCertificateMappingAuthentication>
                    <windowsAuthentication enabled="false" />
                </authentication>
                <access sslFlags="Ssl, SslNegotiateCert, SslRequireCert" />
            </security>
            <defaultDocument enabled="true">
                <files>
                    <clear />
                    <add value="index.php" />
                    <add value="index.htm" />
                    <add value="index.html" />
                </files>
            </defaultDocument>
            <handlers>
                <remove name="PHP53_via_FastCGI" />
                <add name="PHP53_via_FastCGI" path="*.php" verb="GET, PUT, POST, HEAD, OPTIONS, TRACE, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK" modules="FastCgiModule" scriptProcessor="D:\Program Files (x86)\PHP\v5.3\php-cgi.exe" resourceType="Either" requireAccess="Script"
                />
            </handlers>
        </system.webServer>
    </location>
</configuration>

最佳答案

默认情况下,PHP v5.3 在 Azure Web App 上可用。它可能会导致您的问题。您可以将 PHP 运行时升级到 v5.5 或更高版本。

enter image description here

将您的处理程序配置替换为以下内容。它应该可以工作。

<handlers>
    <remove name="PHP56_via_FastCGI" />
    <add name="PHP56_via_FastCGI" path="*.php" verb="GET, PUT, POST, HEAD, OPTIONS, TRACE, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK" modules="FastCgiModule" scriptProcessor="D:\Program Files (x86)\PHP\v5.6\php-cgi.exe" resourceType="Either" requireAccess="Script" />
</handlers>

如果您希望继续在 Azure Web 应用程序中运行 PHP 5.3,请按照 How to: Use a custom PHP runtime 中的步骤操作。显式设置站点的 PHP 运行时。

关于php - Azure 网站 PHP API - 不允许使用 500 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45738876/

相关文章:

php - api客户端中的nonce是什么

azure - Azure 上的 StackExchange.Redis 抛出执行获取超时且无连接可用异常

php - 如何使用Vue创建具有值的复选框

php - 更新/插入 mysql 查询

Php - 使用 url 获取文件大小

php - 使用来自 ManyToMany 关联的值过滤具有 NOT EXISTS 条件的 DQL 查询

javascript - ArcGIS Javascript api SimpleMarkerSymbol 单击事件

android - 如何在Retrofit中解析Restful api JSON响应?

具有 ADLS Gen 2 安全访问功能的 Azure Databricks

c# - Azure WebRole CloudConfigurationManager.GetSetting 返回 null