Install Sphinx in Linux

Source: Internet
Author: User

1. Go to sphinx to download the corresponding package: sphinx-0.9.8.1.tar.gz (recommended document version)

ExtractsphinxSource code package:

$ Tar xzvf sphinx-0.9.8.1.tar.gz
$ CD sphinx

2. Run the configure configuration program:

  • $./Configure [Options]

    Some parameters can be specified during configuration, mainly as follows:

    --prefix, SpecifyThe location where Sphinx is installed to the system.For example--prefix=/usr/local/sphinx

  • --with-mysql, MySQL installation directory, which must be configured if the directory to which the MySQL database file fails to be searched automatically.
  • --with-pgsql, Same as above, only for pgsql (for pgsql, you can view the http://www.pgsqldb.org/pgsqldoc-cvs/plpgsql.html#PLPGSQL-OVERVIEW)

As follows:./configure -- prefix =/usr/local/sphure -- With-mysql =/usr/local/MySQL

3. Compile:

$ Make

In this step, a problem may occur, that is, the sphsf-undefined reference to 'libiconv' error is reported, the solution is to modify/src/makefile (The makefile under SRC is not the makefile under CSFT), and add-liconv after libs =-lm-lexpat, that is, this row is:
Libs =-lm-lexpat-liconv-L/usr/local/lib

4. Installation

$ Make install

If no errors are generated during compilation, this step will not encounter any problems. If the installation is not correct after completion, you need to go back to the errors encountered during the make process.
In fact, here we can run 3 and 4 together, make & make install
5. Run the test

$ CD/usr/local/sphinx/etc
$ CP sphinx. conf. Dist sphinx. conf
$ VI sphinx. conf

Here, Sphinx provides a simple example. The basic step is to first/Sphinx/etcRename sphsf-. Conf. DIST to sphsf-. Conf, and then modify the configuration in sphsf-. Conf. It mainly changes the MySQL user name, password, and database on your server. The modified location is the lines below source src1 of sphsf-. Conf.

$ Mysql-U test </usr/local/sphple/etc/example. SQL

Here we import the test data prepared by sphinx. We import the data to the test database of MySQL. Of course, the database here should be the same as the SQL _db value specified in the configuration file above (sphsf-. conf. Note: To run this command, if your MySQL command is not added to the environment variable, you must use the complete path and enter the password. For example, if your MySQL is installed in the/usr/local/MySQL directory and the root account password is xxxxxx, the command should be adjusted:
$/Usr/local/MySQL/bin/MySQL-uroot-pxxxxxx test </usr/local/sphple/etc/example. SQL
(In this case, I always report a syntax error in example. SQL during running. I have read the file and have not found any errors. MySQL uses the root permission. Later, there was no way to execute the statement by copying one piece of code. It was found that some spaces were copied to the command line and some would be filtered out .)
$ CD/usr/local/sphinx/etc
$/Usr/local/sphinx/bin/indexer -- all
(All paths must be used for running. Unless you have configured it in the environment, no error will be reported. Indicates that indexer does not exist)
This command is used to create an index. Of course, the data base is the just-imported example. if an error occurs in SQL data, the biggest possible cause is your sphworkflow. the database configuration in conf is incorrect. You need to go back and check and correct it. However, the library files required by sphenders may fail to be found. For example, the following two errors may occur:
/Usr/local/sphinx/bin/indexer:
Error while loading shared libraries: libmysqlclient. so.15: cannot open
Shared object file: no such file or directory

/Usr/local/sphinx/bin/indexer: Error while loading shared libraries:
Libiconv. so.2: cannot open shared object file: no such file or directory
This is mainly because you have not been able to configure the corresponding environment variables after installing some libraries. You can fix this issue by establishing a connection and run the following command:
Ln-S/usr/local/MySQL/lib/libmysqlclient. so.15/usr/lib/libmysqlclient. so.15 (here is so.15 or so.16. You need to go to the MySQL/bin/MySQL installation directory)
Ln-S/usr/local/lib/libiconv. so.2/usr/lib/libiconv. so.2
Here, we assume that your software package is installed in the/usr/local/xxx directory. If you are not installed in the directory, you need to use your own path. If you have not installed the libiconv package, you need to install it. This installation is simple and I will not talk about it.
If a similar error occurs, correct it according to the above method.

$ CD/usr/local/sphinx/etc
$/Usr/local/sphinx/bin/search test

The above command is a search test, and the keyword of the test is test. If the test succeeds, you should see the search result. The string "index 'test1': Query 'test' appears ': returned 3 matches of 3 Total in 0.000 sec ", followed by the result indicating that the operation was successful.

$ CD/usr/local/sphinx/etc
$/Usr/local/sphinx/bin/searchd

Run the preceding command to start the Sphinx process. If there is no error, you can find the Sphinx process through PS-Aux | grep '000000. Haha, you're done!

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.