Compile and install the sphplug extension for linux, coreseek for Chinese word segmentation, and sphplug extension for PHP.

Source: Internet
Author: User
Tarzxvfsphinx-2.1.3.tar.gz unzipping sphinx package cdsphinx-2.1.3.configure -- prefixusrlocalsphinx -- with-mysqlusrlocalmysql Linux environment: CentOS5.5, Ubuntu12.04

1. software download

Sph0000-2.1.3

Coreseek-4.1

2. install sphinx

Tar zxvf sphinx-2.1.3.tar.gz // Unzip the sphinx package cd sphinx-2.1.3./configure -- prefix =/usr/local/sphure -- with-mysql =/usr/local/mysql/

-- Prefix: specifies the installation path of sphinx.
-- With-mysql: specifies the mysql installation path.

sudo make && make install

Compile and install

After the installation is successful, sphinx has three commands:

Indexer index creation command searchd start process command search command line search command

Note: The above commands are in the/usr/local/sphinx/bin directory by default.

3. configure and use sphinx

cd /usr/local/sphinx/etc

Go to The etc directory of sphinx.

sudo cp sphinx.conf.dist sphinx.conf

Copy a configuration file and name it sphsf-. conf.

Import the example. SQL file in the directory to the database named test in the local database.

Modify the configuration information and modify the database connection information to your local database information.

Run the following command to import data and generate an index:

$ cd /usr/local/sphinx/etc$ sudo /usr/local/sphinx/bin/indexer --all

If an error occurs when you execute the indexer command:

ERROR: index 'test1stemmed': sql_connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

It may be because of mysql. the location of sock is changed to/tmp/mysql on the local machine. sock (related to the setting when installing mysql), in sphinx. delete the comment of this line in conf (remove the # sign above ):

#sql_sock                = /tmp/mysql.sock

Execute the above indexer command again. everything is normal.

Run the following command to execute a query:

$ cd /usr/local/sphinx/etc$ sudo /usr/local/sphinx/bin/search test

An error may be reported during search:

index 'test1': search error: query too complex, not enough stack (thread_stack=-2665032K or higher required).

I tried to modify the value of thread_stack in the searchd module in sphsf-. conf, but the problem was not solved. then I commented out the following line in source src1:

#sql_query_info         = SELECT * FROM documents WHERE id=$id

Then run the search command.

Run the following command to start sphinx in the background:

$ cd /usr/local/sphinx/etc$ sudo /usr/local/sphinx/bin/searchd

Run the following command to run the search command using a php script:

$ cd sphinx/api$ php test.php test

The input result is as follows:

Query 'test ' retrieved 3 of 3 matches in 0.022 sec.Query stats:'test' found 10 times in 6 documentsMatches:1. doc_id=1, weight=101, group_id=1, date_added=2014-01-20 10:07:372. doc_id=2, weight=101, group_id=1, date_added=2014-01-20 10:07:373. doc_id=4, weight=1, group_id=2, date_added=2014-01-20 10:07:37

4. install coreseek

tar zxvf coreseek-4.1.tar.gz

Extract two directories: csft-4.1, mmseg-3.2.14

First install mmseg

cd mmseg-3.2.14/./configure --prefix=/usr/local/mmseg

If an error occurs during compilation: "config. status: error: cannot find input file: src/Makefile. in"

Solution:

Sudo apt-get install automakeaclocallibtoolize -- force there is an error after I run it, regardless of it. Automake -- add-missingautoconfautoheadermake clean./configure -- prefix =/usr/local/mmsegmakesudo make install

Install csft (coreseek)

cd csft-4.1/sh buildconf.sh./configure --prefix=/usr/local/coreseek --with-mysql=/usr/local/mysql/ --with-mmseg=/usr/local/mmseg/ --with-mmseg-includes=/usr/local/mmseg/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg/lib/ sudo make && make install

After the installation is complete, you need to import coreseek/etc/example. copy the SQL file to the local database and then copy the file. conf. dist to csft. conf to modify the database username and password. the test error is the same as that in sphinx.

To use sphinx, you must do the following:

1. data available;

2. create a sphinx configuration file;

3. generate an index;

4. start the searchd service process. The default value is 9312.

5. use PHP to connect to the sphinx service

Start sphinx

cd /usr/local/coreseek/bin/./searchd

Start command

Searchd command parameters:

-C: specify the configuration file

-- Stop

-- Pidfile is used to explicitly specify a PID file

-P: specified port

5. install the sphinx extension in php

sudo pecl install sphinx

If an error occurs: "configure: error: Cannot find libsphinxclient headers"

Solution:

cd coreseek-4.1/csft-4.1/api/libsphinxclient/./configure --prefix=/usr/local/libsphinxclientsudo make && make install

Solution complete!

Go back and execute

./configure --with-php-config=/usr/local/php/bin/php-config --with-sphinx=/usr/local/libsphinxclientsudo make && make install

If "Installing shared extensions:/usr/lib/php5/20090626/sphsions. so" is displayed, the operation is successful.

You can go to this directory and find that a sphpipeline. so file is generated.

Load the so file in php. ini

Extension =/usr/lib/php5/20090626/sphsion. so

Restart apache. if this occurs in phpinfo (), the operation is successful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.