FreeTDS PHP mssql_connect() 刷新时出现 503

FreeTDS PHP mssql_connect() 刷新时出现 503

我们最近在我们的一台 RHEL7 服务器上安装了带有 php56-mssql 的 FreeTDS。除了这个奇怪的问题之外,一切似乎都运行正常。第一次加载使用 mssql_connect() 函数的 php 页面时,该页面会访问 sql server 2012 实例,获取数据并按预期呈现页面。但是,如果我们刷新页面一次,页面将呈现,但不包含任何来自数据库的数据。如果我们第二次刷新,我们会收到以下 503 消息:

Service Temporarily Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

如果我们继续刷新第三次,页面将按预期呈现所有数据。此外,在故障排除过程中,我注意到,如果我们加载页面,等待约 15 秒,然后刷新,页面将按预期加载。

当探索 error_log 时,我们看到以下消息:

[Fri Oct 21 12:37:44.971872 2016] [proxy_fcgi:error] [pid 14052:tid 140504888997632] [client xx.xxx.xx.xx:xxxxx] AH01071: Got error 'PHP message: PHP Warning:  mssql_select_db(): 2 is not a valid MS SQL-Link resource in /var/www/vhosts/example.com/e0/conn.php on line 6\nPHP message: PHP Warning:  mssql_init(): 2 is not a valid MS SQL-Link resource in /var/www/vhosts/example.com/httpdocs/e1/search.php on line 16\nPHP message: PHP Warning:  mssql_bind() expects parameter 1 to be resource, boolean given in /var/www/vhosts/example.com/httpdocs/e1/search.php on line 17\nPHP message: PHP Warning:  mssql_bind() expects parameter 1 to be resource, boolean given in /var/www/vhosts/example.com/httpdocs/e1/search.php on line 18\nPHP message: PHP Warning:  mssql_execute() expects parameter 1 to be resource, boolean given in /var/www/vhosts/example.com/httpdocs/e1/search.php on line 19\nPHP message: PHP Warning:  mssql_free_statement() expects parameter 1 to be resource, boolean given in /var/www/vhosts/example.com/httpdocs/e1/search.php on line 20\nPHP message: PHP Warning:  mssql_fetch_array() expects parameter 1 to be resource, null given in /var/www/vhosts/example.com/httpdocs/e1/search.php on line 23\nPHP message: PHP Notice:  Undefined offset: 0 in /var/www/vhosts/example.com/httpdocs/e1/search.php on line 53\nPHP message: PHP Notice:  Undefined offset: 0 in /var/www/vhosts/example.com/httpdocs/e1/search.php on line 60\n', referer: http://example.com/contacts/
[Fri Oct 21 12:37:45.347450 2016] [proxy_fcgi:error] [pid 14109:tid 140504956139264] (104)Connection reset by peer: [client xx.xxx.xx.xx:xxxxx] AH01075: Error dispatching request to :, referer: http://example.com/e1/
[Fri Oct 21 12:37:45.347625 2016] [include:warn] [pid 14109:tid 140504956139264] [client xx.xxx.xx.xx:xxxxx] AH01374: mod_include: Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed: /error_docs/maintenance.html, referer: http://example.com/e1/

有什么建议吗?我不知道为什么会发生这种情况!?

更新

使用此连接测试了另一个页面。第一次加载正常,但如果在 15 秒内再次请求,则直接连接失败:

AH01071: Got error 'PHP message: PHP Warning:  mssql_connect(): Unable to connect to server: theServerName

答案1

在这种情况下,问题恰好是我们的服务器设置为将此应用程序作为“由 Apache 提供的 FPM 应用程序”运行,而我们应该将此应用程序设置为作为“由 Apache 提供的 FastCGI 应用程序”运行。

相关内容