Get Social

Installing and configuring sphinx on centos 5

This information is suitable for sphinx versions 2.0.9 and below (also sphinx 1.x).
If you need to install and configure version 2.2.x (2.2.11, for example), then see here >>

[1] How to install sphinx on centos 5

Where to search for information?

As always – first we look, that is in search on query “installation sphinx on centos”.
We open several tabs and work on it. And of course, we look at the official documentation (http://sphinxsearch.com/docs)
yum search sphinx
yum install sphinx
cat /etc/redhat-release
CentOS release 5.9 (Final)

wget http://sphinxsearch.com/files/sphinx-2.0.9-1.rhel5.i386.rpm
yum --nogpgcheck localinstall sphinx-2.0.9-1.rhel5.i386.rpm

rpm -Uvh sphinx-2.0.9-1.rhel5.i386.rpm
error: Unsatisfied dependencies:
libmysqlclient.so.15 required for sphinx-2.0.9-1.rhel5.i386
libmysqlclient.so.15(libmysqlclient_15) required for sphinx-2.0.9-1.rhel5.i386

I go to http://sphinxsearch.com/docs/current.html#installing
wget http://sphinxsearch.com/files/sphinx-2.0.9-release.tar.gz

cd sphinx-2.0.9-release
./configure
make

libsphinx.a(sphinx.o): In function `xmlUnknownEncoding':
/root/install/sphinx-2.0.9-release/src/sphinx.cpp:22846: undefined reference to `libiconv_open'
/root/install/sphinx-2.0.9-release/src/sphinx.cpp:22864: undefined reference to `libiconv'
/root/install/sphinx-2.0.9-release/src/sphinx.cpp:22870: undefined reference to `libiconv_close'
collect2: ld completed with a return code 1

How to fix this error “collect2: ld completed with a return code 1” ?

replace:
LIBS = -lexpat -ldl -lm -lz -L/usr/local/lib -lrt -lpthread
to
LIBS = -lexpat -liconv -ldl -lm -lz -L/usr/local/lib -lrt -lpthread
profit!

make
make install

[2] How to configure sphinx on centos 5

just in case, backup the original configs:
cd /usr/local/etc
cp -i sphinx-min.conf.dist sphinx-min.conf.dist.copy
cp -i sphinx.conf sphinx.conf.copy

set the configuration for own database
nano /usr/local/etc/sphinx.conf

We will create the folders listed in the config (otherwise we’ll get errors … 🙂 )
mkdir /home/user/sphinx_data/
mkdir /var/log/sphinx/

start service:
searchd --config /usr/local/etc/sphinx.conf

check that the service on the required ports is working
lsof -i tcp:9312
lsof -i tcp:9306

check that the log files have been created:
ls -lh /var/log/sphinx/

Useful commands for sphinx search service

create index:
indexer --config /usr/local/etc/sphinx.conf --all

update index:
indexer --config /usr/local/etc/sphinx.conf --rotate

search test in the console:
search -q --config /usr/local/etc/sphinx.conf -a 123
or simple:
search -q 123
In order to use the search on the site, you need to use the Sphinx API for PHP.
This is the library that comes with the distribution. We find where it is:
locate sphinxapi.php
<?php
.....
// Plug sphinx-api
require_once ("sphinxapi.php");
.....
?>

Add cron task to the rotation every 15 minutes (the indexer path is full, because the cron are usually do not know where to look for executable files):
*/15 * * * * /usr/local/bin/indexer --config /usr/local/etc/sphinx.conf --rotate > /dev/null 2>&1

[3] How to make searchd (sphinx) start on reboot?

1) Beautiful method – as described in this article.

2) A simple method is to check in the cron every minute whether searchd is started and run it, if necessary. Criterion – check the existence of a pid-file:
* * * * * if [ ! -f /var/log/sphinx/searchd.pid ]; then /usr/local/bin/searchd --config /usr/local/etc/sphinx.conf; fi > /dev/null 2>&1

 

Update, 21.12.2016: This settings for Sphinx 1.x и 2.0.x; to learn how to install and configure Sphinx versions 2.2.x read: Installing and Configuring Sphinx 2.2.11 (Yii with delta Indexes) on Ubuntu / Debian and RHEL / CentOS 7

Selecting a CMS for a business card site

Strangely enough, I started my expirience with CMS via drupal (later I learned that it was also CMF), then I got expirience with WordPress. Now, when again it is necessary to make a new project, I wanted to expand my expirience with CMS and decided to do the following.
There are a lot of recommendations on the web that take as a basis for a business card site – from static html to monsters like joomla. I decided to just take 4 different CMS (which I’m not familiar with) and install them on the VPS. I’ll choose the one that will immediately like.

We make preparations (the domain has already been registered in advance). Let’s agree that MY-NEW.DOMAIN is the domain name.

cd /var/www/
mkdir {getsimple,hostcms,joomla,dle}-MY-NEW.DOMAIN

Download all CMS:
wget http://get-simple.info/dreamhost-pickup/GetSimpleCMS_3.3.0.zip
wget http://www.hostcms.ru/download/6/HostCMS.Free_6.1.tar.gz
wget http://joomlacode.org/gf/download/frsrelease/18934/133835/Joomla_3.2.0_Full_Package_Russian.zip
wget http://dle-news.ru/files/dle10.0_trial.zip

Extract to the appropriate directories:
unzip -d getsimple-MY-NEW.DOMAIN/ GetSimpleCMS_3.3.0.zip
mv getsimple-MY-NEW.DOMAIN/GetSimpleCMS-3.3.0/* getsimple-MY-NEW.DOMAIN/
rmdir getsimple-MY-NEW.DOMAIN/GetSimpleCMS-3.3.0
tar -xz -C hostcms-MY-NEW.DOMAIN/ -f HostCMS.Free_6.1.tar.gz
unzip -d joomla-MY-NEW.DOMAIN/ Joomla_3.2.0_Full_Package_Russian.zip
unzip -d dle-MY-NEW.DOMAIN/ dle10.0_trial.zip

Set privileges:
chown -R nobody:nogroup {getsimple,hostcms,joomla,dle}-MY-NEW.DOMAIN

Now we edit Apache config file:
nano /etc/apache2/conf.d/MY-NEW.DOMAIN.conf

——————————————
<VirtualHost *:80>
ServerName MY-NEW.DOMAIN
ServerAlias www.MY-NEW.DOMAIN
DocumentRoot /var/www/MY-NEW.DOMAIN # this line will be changed for each CMS
<Directory "/var/www/MY-NEW.DOMAIN"> # and this line will be changed for each CMS
AllowOverride All
Order deny,allow
Allow from all
AddHandler application/x-httpd-php .php .html
</Directory>
</VirtualHost>

——————————————

Apply config changes with apache process:
apachectl graceful

We create a database (for DLE example) for those CMSs that need it:

mysql -u root -p
CREATE DATABASE dleuserdb;
GRANT ALL PRIVILEGES ON dleuserdb.* TO "dleuserdb"@"localhost" IDENTIFIED BY "dleuserdbpass";
FLUSH PRIVILEGES;
EXIT

So which CMS to choose for a business card site? Notes.

— GetSimpleCMS —

Works without Mysql and uses xml format for data storage. What else do you need for a business card site? Indeed, it is very simple. When the files are uploaded, go to the link:
http://MY-NEW.DOMAIN/admin
Following the prompts, install the CMS (I had to change the rights to the folders data and backups, as well as install the php5-gd and php5-curl packages to get the gd library and cURL support).

— hostcms —

Immediately starts the installer. Appearance – I liked. Further, it asked to accept an agreement where one of the items is the obligatory placement of a link to the official website … (3.4. A user of a free edition of the Software product is required to place an active, indexed and visible hyperlink on each site using the Software Product site management HostCMS» to the website of the Vendor http: slashslashwwwpointhostcmspointru in the global Internet.) Somehow I did not like it … Well, we go to the end. Click “Next” (I did not install xslt support, set it: aptitude install php5-xsl; I also had to change the permissions on the file: modules/core/config/database.php and to the folder: hostcms-user.pp.ua/hostcmsfiles/tmp)

— dle —

After I transferred the contents of the subfolder upload to the root folder of the site, I immediately got into the installer. All that needed to be done later was to disable output buffering. To do this, open the php.ini file and put the value of the parameter: “output_buffering = Off” and also change the permissions on some files and folders with the chmod command.

— joomla —

I just didn’t get around to CMS Joomla.

upd (12.12.16). and I’ll get not around to it…

How to encrypt a backup and upload it on ftp or sftp?

If you need to upload backup to a third-party ftp-server (archive, just a file), however, you need to ensure that important information does not fall into the wrong hands, before uploading, encrypt it with a password and then upload it.

We encrypt the file with the openssl command

openssl aes-256-cbc -salt -in FILE -out FILE.aes -k PASSWORD
(openssl there are in most Linux distributions, and you can also install it in windows and mac os)
To request a password, you need to remove the “-k PASSWORD”.
You can decrypt with the command
openssl aes-256-cbc -d -salt -in FILE.aes -out FILE -k PASSWORD

 

How to upload to ftp (using curl best)

curl -s -T FILE -u USER:PASSWORD ftp://ftpserverhostname

 

How to upload to sftp

rsync -avz -e ssh USER@PASSWORD:/remote/directory/ /current/directory/file

 

How to upload to sftp with curl

short answer – use rsync over ssh and do not suffer 🙂