Install and configure Sphinx search engine for WordPress on CentOS RedHat
1, Download Sphinx search engine from Sphinx
wget http://www.sphinxsearch.com/downloads/sphinx-0.9.8.tar.gz
tar xzvf sphinx-0.9.7.tar.gz
2, Install MySQL mysql-devel
yum install mysql-devel
3, Configure Sphinx
cd sphinx-0.9.8
./configure --prefix /home/sphinx/sphinxsearch --with-mysql
make
make install
4, Create a configuration file
cd /home/sphinx/sphinxsearch/etc
cp sphinx.conf.dist sphinx.conf
5, Edit sphix.conf
vi sphinx.conf
Configuration file sphinx.conf for wordpress
source mywhiteboard
{
type = mysql
sql_host = localhost
sql_user = mywhiteboard
sql_pass = a1b2c3z4y5x6
sql_db = ivdb
sql_port = 3306
sql_query = SELECT id, post_title, post_content FROM wp_posts
sql_query_info = SELECT * FROM wp_posts WHERE id =$id
}
index mywhiteboard
{
source = mywhiteboard
path = /home/sphinx/sphinxsearch/var/data/mywhiteboard
docinfo = extern
mlock = 0
morphology = stem_en
enable_star=1
stopwords = /home/sphinx/sphinxsearch/var/data/stopwords.txt
min_word_len = 3
charset_type = sbcs
min_prefix_len = 0
min_infix_len = 3
html_strip = 1
html_remove_elements = style, script
}
indexer
{
mem_limit = 256M
}
searchd
{
port = 3312
log = /home/sphinx/sphinxsearch/var/log/searchd.log
query_log = /home/sphinx/sphinxsearch/var/log/query.log
read_timeout = 5
max_children = 30
pid_file = /home/sphinx/sphinxsearch/var/log/searchd.pid
max_matches = 1000
seamless_rotate = 1
preopen_indexes = 0
unlink_old = 1
}
6, make a directory for indexes
mkdir
/home/sphinx/sphinxsearch/var/data/mywhiteboard
7, Start indexer:
/home/sphinx/sphinxsearch/bin/indexer
--config /home/sphinx/sphinxsearch/etc/sphinx.conf --allSphinx 0.9.8-release (r1371)
Copyright (c) 2001-2008, Andrew Aksyonoffusing config file '/home/sphinx/sphinxsearch/etc/sphinx.conf'...
indexing index 'mywhiteboard'...
collected 1104407 docs, 1938.9 MB
sorted 6551.8 Mhits, 98.5% donedone
total 1104407 docs, 1938867135 bytes
total 5126.826 sec, 378180.78 bytes/sec, 215.42 docs/sec
8, To test if it is working:
/home/sphinx/sphinxsearch/bin/search
--config /home/sphinx/sphinxsearch/etc/sphinx.conf insulin....
20. document=9345, weight=3
id=9345
....
words:
1. 'insulin': 30601 documents, 109926 hits
9, See how much disk space the indexer used:
Tags: Linux
ls -la
/home/sphinx/sphinxsearch/var/data/mywhiteboard
drwxr-xr-x 3 root root 4096 Oct 21 16:20 .
drwxr-xr-x 4 root root 4096 Sep 11 20:08 ..
-rw-r--r-- 1 root root 0 Oct 21 15:32 mywhiteboard.spa
-rw-r--r-- 1 root root 14925566596 Oct 21 16:20 mywhiteboard.spd
-rw-r--r-- 1 root root 237 Oct 21 16:20 mywhiteboard.sph
-rw-r--r-- 1 root root 57254921 Oct 21 16:20 mywhiteboard.spi
-rw-r--r-- 1 root root 0 Oct 21 15:32 mywhiteboard.spm
-rw-r--r-- 1 root root 22721504506 Oct 21 16:20 mywhiteboard.spp
kamal said,
May 25, 2009 @ 8:13 am
Hi, and thanks to google that i come her :)
I’m searching about how to setup sphinx search engine for WordPress themes, and i find this tutorial, but i’s so so hard for a beginner in PHP (and English too) like me ;)
so have you a easiest tutorial of how to install and integrate the sphinx into WordPress Theme?
Is it possible to do that in XAMPP local Host?
And finally thanks for all
RSQ said,
June 1, 2009 @ 6:07 am
thanks for sharing the gr8 article
Mr.Muscul said,
June 18, 2009 @ 4:04 am
Good job, pal.
shoeb saifee said,
August 28, 2009 @ 2:39 am
great work
Karthik said,
November 27, 2010 @ 11:08 am
Hi,
Really nice post. I was sphinx search in wordpress on linux based computer(Ubuntu).Just can you tell me will the database get reindex if it has any updates or we have to manually re-index each and every time. Because we are trying to make the reindex automated. Can you help us in fix that issue.Looking forward to your reply…
Yaroslav Vorozhko said,
January 28, 2011 @ 8:14 am
Why don’t use WordPress Sphinx Search plugin?
http://wordpress.org/extend/plugins/wordpress-sphinx-plugin/
BTW, it contain Installation Wizard for Sphinx Search.