23.12.2010

PECL: установка Sphinx для PHP

СНАЧАЛА ОШИБКА, А НИЖЕ КАК ВСЕ СНАЧАЛА ПРАВИЛЬНО ДЕЛАТЬ.
_____
При установке sphinx из pecl возникает ошибка:

# pecl install sphinx
downloading sphinx-1.1.0.tgz ...
Starting to download sphinx-1.1.0.tgz (12,870 bytes)
.....done: 12,870 bytes
4 source files, building
running: phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
 1. Please provide the installation prefix of libsphinxclient : autodetect
1-1, 'all', 'abort', or Enter to continue:
building in /var/tmp/pear-build-root/sphinx-1.1.0
running: /tmp/pear/temp/sphinx/configure --with-sphinx
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc and cc understand -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib
checking for PHP extension directory... /usr/lib/php5/20060613
checking for PHP installed headers prefix... /usr/include/php5
checking for re2c... re2c
checking for re2c version... 0.13.5 (ok)
checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no
checking for sphinx support... yes, shared
checking for libsphinxclient headers in default path... not found
configure: error: Cannot find libsphinxclient headers
ERROR: `/tmp/pear/temp/sphinx/configure --with-sphinx' failed
#


Такое происходит, если не установлен заранее libsphinxclient.
А значит действуем по плану Б!

Напоминаю, как мы ставили до этого сам Sphinx, если Вы этого еще не сделали:
wget "http://sphinxsearch.com/downloads/sphinx-0.9.9.tar.gz"
tar xzf sphinx-0.9.9.tar.gz
cd sphinx-0.9.9./configure
make
checkinstall
dpkg -i sphinx_0.9.9_x86_64.deb
(пакет может называться по другому. Зависит от того, что Вы указали на этапе checkinstall)
Все, Sphinx установлен.


Теперь переходим возвращаемся к установке libsphinxclient.
Находясь там же, откуда ставили Sphinx, (cd sphinx-0.9.9), переходим глубже:
cd api/libsphinxclient ./configure
Далее сложность: make не пробежит. Вот багрепорт.
Потому добавляем в файл: 
vi +281 sphinxclient.c
−−− void sock_close ( int sock );
+++ static void sock_close ( int sock );
make
make install
Итак мы получили хидеры в директории с библиотеками: /usr/local/lib/libsphinxclient.so
Пробуем:
pecl install sphinx
Так как это(/usr/local/lib/) дефолтное место библиотек, то нам нужно нажать Enter при вопросе.
Итак получили библиотеку: /usr/lib/php5/20060613/sphinx.so
Добавляем ее в конфигурацию php.ini: 
echo "extension=sphinx.so" > /etc/php5/conf.d/sphinx.ini
Проверяем:
php -i | grep sphinx
И осталось рестартануть Apache:
invoke-rc.d apache2 restart
И было бы хорошо дать отсюда ссылку на замечательную статью: 
Создание ознакомительного поискового движка на Sphinx + php



4 комментария:

  1. Спасибо, друг. Если бы не ты - я сдох. Сильно помогло.

    ОтветитьУдалить
  2. Анонимный04.12.2012, 01:27

    С недавних пор, поддерживаем php5-sphinx в своём репозитории.
    Наряду со свежим php5 из dotdeb и самим sphinx.
    Если будет интересно — http://deb.one2team.ru/

    Подключать необязательно, можно просто скачать.

    ОтветитьУдалить
    Ответы
    1. Спасибо, Дмитрий. Буду иметь ввиду.
      Хотя конечно подключать репозитории незнакомых людей очень опасно и недопустимо в некоторых случаях :)

      Удалить
    2. Анонимный16.02.2013, 10:19

      Ну, все мейнтейнеры нам не знакомы )
      Доверие зарабатывается временем.

      Удалить