Friday, April 8, 2011

Install Sphinx as Service on Redhat/CentOS

Thanks Steve Kamerman

Create this searchd script under /etc/init.d, & alter the SUDO_USER & BASEPATH to fit your environment.

#!/bin/bash## Init file for searchd## chkconfig: 2345 55 25## description: searchd ## USE "chkconfig --add searchd" to configure Sphinx searchd service## by Steve Kamerman April 14, 2010# http://www.tera-wurfl.com# public domainSUDO_USER=sphinxBASE_PATH=/usr/local/sphinxPID_FILE=$BASE_PATH/var/log/searchd.pidCONFIG_FILE=$BASE_PATH/etc/sphinx.confEXEC_PATH=$BASE_PATH/binLOG_PATH=$BASE_PATH/var/logDATA_PATH=$BASE_PATH/var/dataRETVAL=0prog="searchd"do_config() {	chown -R $SUDO_USER $EXEC_PATH	chown -R $SUDO_USER $CONFIG_FILE	chown -R $SUDO_USER $DATA_PATH	chown -R $SUDO_USER $LOG_PATH	chmod 600 $CONFIG_FILE	chmod u+rwx $EXEC_PATH/*	chmod -R u+rw,go-rwx $DATA_PATH	chmod -R u+rw,go-rwx $LOG_PATH}do_start() {	echo "Starting $prog"	sudo -u $SUDO_USER $EXEC_PATH/$prog --config $CONFIG_FILE	RETVAL=$?	echo	return $RETVAL}do_stop() {	echo "Stopping $prog"	if [ -e $PID_FILE ] ; then		sudo -u $SUDO_USER $EXEC_PATH/$prog --stop		sleep 2		if [ -e $PID_FILE ] ; then			echo "WARNING: searchd may still be alive: $PID_FILE"		fi	fi	RETVAL=$?	echo	return $RETVAL}do_status() {	RETVAL=$?	if [ -e $PID_FILE ] ; then 		sudo -u $SUDO_USER $EXEC_PATH/$prog --status		echo "---"		echo "$prog is running (`cat $PID_FILE`)"	else		echo "$prog is not running"	fi	return $RETVAL}do_reindex() {	echo "Reindexing all $prog indices"	if [ -e $PID_FILE ] ; then		sudo -u $SUDO_USER $EXEC_PATH/indexer --all --rotate	else		sudo -u $SUDO_USER $EXEC_PATH/indexer --all	fi	echo "done."	echo	RETVAL=$?	return $RETVAL}case $* inconfig)	do_config	;;start)	do_start	;;stop)	do_stop	;;status)	do_status	;;reindex)	do_reindex	;;*)	echo "usage: $0 {start|stop|config|status|reindex}" >&2	exit 1	;;esacexit $RETVAL

Then alter the permission to make it executable.

chown root:root /etc/init.d/searchdchmod 755 /etc/init.d/searchd

Finalise, make it automatically start on system boot

chkconfig --level 345 searchd on

Now you can use

service searchd start/stop/status

to control the sphinx service

Wednesday, February 23, 2011

Awesome new feature - sql_attr_string in sphinx search 1.10

Sphinx search engine 1.10 brings a new attribute sql_attr_string which allows sorting the search result by string rather than integer before. This extremely helpful in my current project, however, this version of sphinx is still in beta, hope they can release the stable version soon.

Live Messenger 100% CPU usage? Abandon it!!!

Once Live Messenger is running, the CPU usage will be high especially it’s stupid embedded ad system play the flash content. Yes, abandon live messenger!!!!! Use sth else instead, I personally recommend Amsn or Pidgin, they are both open source, free to use & NO FLASH AD.

Friday, February 18, 2011

Apache reverse proxy on windows

At moment, we to use apache reverse proxy to handle HTTP request to different server in LAN with a single IP address, there is the configuration
in http.conf, enable following modules

mod_proxy.so(module_proxy)mod_proxy_http.so(module_proxy_http)mod_cache.so(module_cache)mod_disk_cache.so(module_disk_cache)And add your virtual host:ServerName example.comProxyPass / http://example.com/ProxyPassReverse / http://example.com/CacheRoot "d:/apache_cache/" CacheEnable disk /images/CacheDirLevels 2CacheDirLength 1

You will need to edit your host file for “example.com” to your LAN IP address.

Saturday, November 6, 2010

Ubuntu 10.10, new Linux experience

Ubuntu 10.10 bring absolutely new experience of usability with much better multimedia/game experiencing. Since wine1.2 has full support most popular game such as World of Warcraft, it runs perfectly on my pc

PPStream moreover has released the first offical version for Linux, I have been expected this more than 3 years already.

Chinese Telecommunication moreover released MiguMusic Player, which is a free online streaming music player based on Java & QT4, it is the first Chinese online music player for Linux

The future, Linux has been launched many years yet sucks at the user desktop due to lacking of satisfactory software runs on it. However, more & more software company start to aware the grown of Linux users & the potential market, the Linux desktop is predictably becoming stronger though there is a quite far away between it rival – Windows !!! yet we all expecting.

Wednesday, November 3, 2010

Integrate open source secureimage library with CodeIgniter

Heres how:
1.) Download the open source securimage library from:
http://www.phpcaptcha.org/.

2.) Copy the library in your codeigniter’s application/library folder.

3.) Create a function in your codeigniter’s controller’s class (example index)

 function securimage() {$this->load->library('securimage');$img = new Securimage();$img->show(); // alternate use:  $img->show('/path/to/background.jpg');}

4.) In the view where you will place the captcha, insert this line:

<img src="<?=site_url('index/securimage')?>" alt='captcha' />

site_url() – gives the base url with index.php in the end
index – controller
securimage – is the function

Monday, November 1, 2010

Build mini home server with sheevaplug

If you are reading this artile, probably you are looking for a mini home server, it doesn’t need to be powerful yet can do the most usual task such as http server, ftp, ssh, torrent download client, svn, git server. it should be small & quiet. This article introduce a new way of building a mini home linux server with Sheevaplug, a robust Linux ARM.

Sheevaplug cames with 1.2G cpu & 512 ram plus 512 flash storage, the release date was March 2009 so it is not a new product, I received it immediately after it released, & have been using it for quite a while.

There are a lot of article introduces to install another Linux such as debian, fedora on Sheevaplug, & install the OS to a external harddrive, yet I’m lazy :), I wanna do something simple really, I dont wanna alter the boot to make things complicate as I believe technology is to make the life easier :D.

So what can sheevaplug brings to us, as far as I testing, in its 512MB internal memory, you can install following softwares

nginx
php5 & some externsions such as curl, gd2
mysql server 5
torrentflux
samba server
pureftpd
sendmail
python

With these software, you can do a lot of things with your imagination.
A Bittorrent Client, a Samba Server stores your media file, host a personal blog such as wordpress or any php based web application.

The installation is really simple, Sheevaplug official released UBUNTU came with aptitude command

$aptitude php5 nginx mysql-server-5 pureftpd torrentplux samba

Now you will have used around 420MB of the flash disk, there are still 50MB free space left, I will strongly recommend use an external harddisk to store your data files. Currently I’m using an 120 GB USB external harddisk which was bought in 2003.

  1. Format your USB external harddisk.
    $mkfs.ext3 /dev/sda1
  2. Create a directory /mnt/usb.
    $mkdir /mnt/usb
  3. Mount USB drive.
    $mount -t /dev/sda1 /mnt/usbln -s /data /mnt/usb
  4. Add it in rc.local
    mount -t /dev/sda1 /mnt/usb

Now you have the usb dirve which is mounted in /mnt/usb & link to /data, then you can alter the configure file for mysql,nginx,pure-ftpd data & log files in to /data/mysql, /data/logs/nginx etc.

Finally, you obtain a full running nignx+php+fastcgi+mysql+pureftpd+torrentflux running in a sheevaplug, only used its 420mb internal flash drive.