Sphinx可以从linux控制台运行,但不能从php api运行

Sphinx可以从linux控制台运行,但不能从php api运行,php,sphinx,Php,Sphinx,我的sphinx在linux控制台上运行正常 This program (CLI search) is for testing and debugging purposes only; it is NOT intended for production use. [root@coinsaver sphinx]# search -i product -q iphone Sphinx 2.1.8-id64-release (rel21-r4675) Copyright (c) 2001-2014,

我的sphinx在linux控制台上运行正常

This program (CLI search) is for testing and debugging purposes only;
it is NOT intended for production use.
[root@coinsaver sphinx]# search -i product -q iphone
Sphinx 2.1.8-id64-release (rel21-r4675)
Copyright (c) 2001-2014, Andrew Aksyonoff
Copyright (c) 2008-2014, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/etc/sphinx/sphinx.conf'...
index 'product': query 'iphone ': returned 88 matches of 88 total in 0.014 sec

displaying matches:
1. document=205267, weight=2773
2. document=470963, weight=2696
3. document=432191, weight=1696
4. document=125460, weight=1642
5. document=186938, weight=1642
6. document=199461, weight=1642
7. document=222081, weight=1642
8. document=249572, weight=1642
9. document=310231, weight=1642
10. document=395051, weight=1642
11. document=395052, weight=1642
12. document=430649, weight=1642
13. document=438066, weight=1642
14. document=468067, weight=1642
15. document=470947, weight=1642
16. document=470961, weight=1642
17. document=471161, weight=1642
18. document=482581, weight=1642
19. document=484640, weight=1642
20. document=490590, weight=1642

words:
1. 'iphon': 88 documents, 97 hits
但在重新启动后,它无法从PHP API工作

$sphinx = new SphinxClient();
// options....
$result = $sphinx->Query("$string*", '*');
它返回false。在我重新启动服务器之前,它就工作了,看起来Nginx和Sphinx不再合得来了,我甚至不知道从哪里开始寻找

结果
searchd--状态

searchd status
--------------
uptime: 361
connections: 1
maxed_out: 0
command_search: 0
command_excerpt: 0
command_update: 0
command_keywords: 0
command_persist: 0
command_status: 1
command_flushattrs: 0
agent_connect: 0
agent_retry: 0
queries: 0
dist_queries: 0
query_wall: 0.000
query_cpu: OFF
dist_wall: 0.000
dist_local: 0.000
dist_wait: 0.000
query_reads: OFF
query_readkb: OFF
query_readtime: OFF
avg_query_wall: 0.000
avg_query_cpu: OFF
avg_dist_wall: 0.000
avg_dist_local: 0.000
avg_dist_wait: 0.000
avg_query_reads: OFF
avg_query_readkb: OFF
avg_query_readtime: OFF

此外,自重新启动后,sphinx查询日志中没有任何条目。

AHA!重新启动后,我的服务器决定将Sphinx的端口从9312更改为3312不要问我怎么做,我只是简单地重新启动了

我运行此命令查看开放端口(CENTOS)
$netstat-tulpn | less

tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      4928/php-fpm
tcp        0      0 127.0.0.1:27017             0.0.0.0:*                   LISTEN      1166/mongod
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      4645/mysqld
tcp        0      0 0.0.0.0:3690                0.0.0.0:*                   LISTEN      1565/svnserve
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      3428/nginx
-----------------------------------------------------------------------------------------
tcp        0      0 127.0.0.1:3312              0.0.0.0:*                   LISTEN      3278/searchd
-----------------------------------------------------------------------------------------
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      529/sshd
tcp        0      0 :::22                       :::*                        LISTEN      529/sshd
所以通过改变这个

$sphinx->SetServer('localhost',9312)

对此

$sphinx->SetServer('localhost',3312)


我的噩梦结束了。因此,即使您有很好的理由重新启动生产服务器,也应该三思而后行,特别是如果您不是linux专家的话。

您是否尝试过在出现启动问题时重新启动Sphinx?Sphinx在未在cli模式下运行时是否使用了正确的配置文件?@fred2我运行了searchd--stop;searchd--config/etc/sphinx/sphinx.conf,但它没有帮助。。。我没有在PHP代码中指定任何配置更改,也没有更改任何内容,只是重新启动了。您可以发布var_dump($result)?i、 它只是返回false还是返回某种错误代码?表示应该有一个状态键来提示任何错误。@fred2返回false。没有错误。没有查询日志条目,绝对没有任何线索。getLastError应该明确地发现了这一点。应该说“连接到..”。。失败'@barryhunter-no。这是我做的第一件事,但奇怪的是它没有