【问题标题】:Azure Websites PHP API - 500 Method Not Allowed onAzure 网站 PHP API - 500 方法不允许
【发布时间】:2023-03-09 16:53:02
【问题描述】:

我刚刚在本地服务器上完成了 PHP API,它运行良好。现在我尝试在 Azure Web App 上部署它,但在任何 get/post 请求期间都出现错误,例如:

这是我的 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 api azure


【解决方案1】:

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

将您的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 应用程序中运行 PHP 5.3,请按照How to: Use a custom PHP runtime 中的步骤明确设置您网站的 PHP 运行时。

【讨论】:

猜你喜欢
  • 2013-04-01
  • 2021-12-07
  • 2017-11-30
  • 1970-01-01
  • 2012-03-21
  • 2013-03-21
  • 2016-01-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多