Sphinx and its configuration

The process of configuring Sphinx in a project, using CentOS 7.x as an example.

In other operating systems, the path to the Sphinx directory may be different.

  1. Install Sphinx on the server.

    The minimum recommended version is 2.2.11+.

  2. In the project's admin panel, specify the connection parameters for Sphinx in the "Site Settings / System Settings / Others / Sphinx" section.

    Host - 127.0.0.1 (default)

    Port - 9306 (default)

    Path - absolute path to the Sphinx data directory - /var/lib/sphinx/ (default)

    Version - the version of Sphinx installed on the server

  3. Run the console command to generate an up-to-date Sphinx configuration file.

    cd /path/to/project/public_html/
    php index.php bff=sphinx
    

    After that, an up-to-date configuration file /config/sphinx.conf will be generated for your project.

    This command needs to be executed again when accessing the database is changed.

  4. Copy the contents of the configuration file /config/sphinx.conf.global to the system configuration file for Sphinx /etc/sphinx/sphinx.conf

    In this file, specify the path to the /config/sphinx.conf file in your project in the files block, for example:

    files=(
         "/path/to/project/config/sphinx.conf"
    )
    
  5. Check the correctness of indexing by executing the command:

    indexer --all --rotate
    
  6. Start the searchd service and make sure it will automatically start after server reboot.

  7. Configure cron tasks for indexing:

    For Classifieds they are as follows:

    # Items:
    4 3 * * * indexer itemsIndexMain --quiet --rotate
    1-59/5 * * * * indexer itemsIndexDelta --quiet --rotate; indexer --merge itemsIndexMain itemsIndexDelta --rotate
    # Shops (if you use this module):
    4 7 * * * indexer shopsIndexMain --quiet --rotate
    2-59/5 * * * * indexer shopsIndexDelta --quiet --rotate; indexer --merge shopsIndexMain shopsIndexDelta --rotate
    
  8. Enable the use of Sphinx in the relevant sections of "Site Settings / System Settings".