[精讚] [會員登入]
1705

[Centos7] 安裝sphinx+php7

在centos7上安裝sphinx,在PHP7上運作正確

分享此文連結 //n.sfs.tw/11054

分享連結 [Centos7] 安裝sphinx+php7@新精讚
(文章歡迎轉載,務必尊重版權註明連結來源)
2019-10-24 05:11:26 最後編修
2017-05-12 15:54:27 By 張○○
 

自動目錄

SPHINX似乎沒有跟上PHP7的更新腳步,還好有大陸的朋友提供了解決方法[1][2],到目前為止很有效。

OS

CentOS Linux release 7.3.1611 (Core)
PHP 7.0.18 (cli) (built: Apr 15 2017 07:09:11) ( NTS )
mysql  Ver 15.1 Distrib 5.5.52-MariaDB, for Linux (x86_64) using readline 5.1  (Mysql客戶端)

安裝 SPHINX

# wget http://sphinxsearch.com/files/sphinx-2.3.1-1.rhel7.x86_64.rpm
# yum install sphinx-2.3.1-1.rhel7.x86_64.rpm

安裝 PHP library

下載
http://git.php.net/?p=pecl/search_engine/sphinx.git;a=snapshot;h=339e123acb0ce7beb2d9d4f9094d6f8bcf15fb54;sf=tgz

PHP 5.X請下載這個
http://git.php.net/?p=pecl/search_engine/sphinx.git;a=snapshot;h=7d9b13f64621bb0011743110b77e9f30c2f43b9b;sf=tgz

# tar zxvf sphinx-339e123.tar.gz
# cd sphinx-339e123
# phpize
# ./configure
# make
# make install

安裝完後自動會產生
/etc/php.d/sphinx.ini

如果沒有自動產生,就手動新增,裡面只有一行

extension=sphinx.so

/usr/lib64/php/modules/sphinx.so

# systemctl restart httpd

檢查是否有啟動
# php -m | grep 'sphinx'
sphinx

SPHINX設定

有關於sphinx的設定比較複雜,請參看 安裝SPHINX支援中文@新精讚

設定開機啟動
# systemctl enable searchd

啟動SPHINX
# systemctl start searchd

關閉SPHINX
# systemctl stop searchd

SPHINX狀態
# systemctl status searchd

 

錯誤排除

1. 程序起動如果失敗,請檢查  /var/run 中有沒有 sphinx的目錄,權限皆為 sphinx:sphinx

# ll /var/run/sphinx/
-rw-------. 1 sphinx sphinx 5 11月  2 10:42 searchd.pid

延伸閱讀

安裝SPHINX支援中文@新精讚

PHP for sphinx 函式庫安裝@新精讚

參考資料

[1] https://www.ddhigh.com/php/2017/02/28/php7-compile-sphinx-extension.html

[2] https://www.36nu.com/post/205.html

END

你可能感興趣的文章

[CENTOS7] 安裝rrdtool+RRDs+PERL 要讓perl繪圖,安裝rrdtool和RRDs

Linux shell 的date表示法 linux下SHELL中的date表示法

[BASH] 自建檔案拷背程式--把指定的檔案拷背到指定的位置。 Git 是很好用的版本控制程式,但我沒辦法使用。 原因就是資安。用SHELL自建簡易的GIT

[Centos] 安裝及使用postfix,設定虛擬帳號及轉寄 使用postfix來設定虛擬帳號及轉寄

[Centos6] 安裝VNC連線程式 在Centos6桌上環境安裝VNC 連線程式

[Centos7] 新的防火牆firewalld Centos7新的防火牆firewalld 和前面的iptables有很大的不同

隨機好文

PHP for sphinx 函式庫安裝 PECL/sphinx PHP>= 5.2.2 已經能原生支援 sphinx,可是預設的沒有裝,我們得自己裝才能用

[CodeIgniter3] 解決無法上傳特定檔案(.sb2)的問題 上傳時出現The filetype you are attempting to upload is not allowed,要怎麼解決?

設計的工作絕不接受比價 拿買陽春麵的價格想買牛肉麵,寧願倒掉也不賣

[MAC] 安裝APACHE+PHP OS Darwin OpenIDMac1deAir 15.6.0 Darwin Kernel Version 15.6.

[PHP]解決ksort新增的SORT_NATURAL|SORT_FLAG_CASE方法 php>=5.4中ksort函數多了SORT_NATURAL 和 SORT_FLAG_CASE 旗標,對舊版的PHP中要怎麼辦?