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

时间:2017-08-17 15:11:53

标签: 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>

1 个答案:

答案 0 :(得分:3)

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

enter image description here

使用以下内容替换handlers配置。它应该工作。

<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 App中运行PHP 5.3,请按照How to: Use a custom PHP runtime中的步骤显式设置站点的PHP运行时。