Wednesday, March 6, 2013

Install latest Wine [1.5] version on Debian

I don't know why debian loves wine v1.01 ?? an obsolete version of wine. They don't upgrade to the next stable versions. The winehq.org doesn't provide .deb packages for squeeze too.
So here's the way, I've just installed  the latest version of wine on my squeeze ! Just remember that compiling wine from source takes ~ 1h of time...

apt-get build-dep wine
cd /usr/src
wget http://downloads.sourceforge.net/project/wine/Source/wine-1.5.25.tar.bz2
tar -jxf wine-1.5.25.tar.bz2
chown -R nobody:nogroup wine-1.5.25
cd wine-1.5.25
sudo -u nobody ./configure
sudo -u nobody make
make install 

~Mos

Monday, December 24, 2012

Speed improvement

Here's some tips which I  applied recently on one busy ded server and the result was a significant reduce in disk I/O load and so faster speed, lesser load avg.

- mount /tmp in ramdisk : Here's the /etc/fstab file line related to tmp :
none /tmp tmpfs nr_inodes=200k,mode=01777,nosuid,nodev 0 0

Check if php uses /tmp as session.save_path , mysql also uses /tmp as tmpdir (mysqladmin variables | grep tmpdir). I've notices on websites with high join queries, mysql has a lot of I/O in /tmp so it's recommended to mount this to ram instead of hdd.


- Mysql datadir : /var/lib/mysql  , recommended to mount in a SSD disk which will give you much greater performance.

- nginx + php-fpm  : There're lots of resources on web suggesting that nginx+php-fpm have much more performance rather than php via apache2 handler.

- ... I'll update this post if I found/remember new tricks ...

- More ?

Sunday, December 23, 2012

Security improvement : nginx symlink and php-fpm chroot features

I've found the new directive in nginx old documentation :

disable_symlinks if_not_owner; # off | on | if_not_owner

Default value is off ! Setting it to if_not_owner is a good security improve and I recommend it.

Also don't miss php-fpm chroot feature ! You can make a chroot jail for working fpm pool by extracting an OS-template to chrooted folder ! (Select the template which matches your main OS). I had to run the following additional commands to make the dns resolving and php working correctly in chrooted jail :

cd jail-path
mknod -m 666 dev/null c 1 3
mknod -m 666 dev/zero c 1 5
mknod -m 666 dev/random c 1 8
mknod -m 666 dev/urandom c 19
cp /lib/*dns* lib
cp /lib64/*dns* lib64
echo "nameserver 8.8.8.8" > etc/resolv.conf
chown -R user:user .

Friday, December 14, 2012

Install wine with MS Visual C++ and Visual Basic runtimes

I just wanted to use some win downloaders on linux ( Orbit downloader, HiDownload, Net Transport, ... ) but they didn't run correctly on wine.
Install latest version of wine using epel repo on RHEL . Then you'll need to install MS Visual C++ and Visual Basic runtimes to make them working :


wget http://winetricks.org/winetricks
chmod +x winetricks
(apt-get install cabextract OR yum install cabextract)
sh winetricks corefonts vcrun6 vb6run


And that's it !

Thursday, September 6, 2012


XCache is awesome, at least for joomla. I've configured memcached on some high trafficed joomla sites but it didn't work well, even I saw some slowness.
Then I let the xcache to make a chance and it did ! I've seen reduce of load average and increase the speed of page loading using xcache.

Here's how configure xcache 2.x on centos 6.x.
Don't forget to :
- set a password for xcache-admin
- check the right module path in xcache.ini (zend_extension=/usr/lib/php/modules/xcache.so or zend_extension=/usr/lib64/php/modules/xcache.so)



yum install php-devel -y
cd /usr/src
wget http://xcache.lighttpd.net/pub/Releases/2.0.1/xcache-2.0.1.tar.gz
tar -zxf xcache-2.0.1.tar.gz
cd xcache-2.0.1
phpize --clean && phpize
./configure --enable-xcache --enable-xcache-optimizer
chown -R nobody /usr/src/xcache-2.0.1
sudo -u nobody make
make install
echo -e "[xcache-common]" > /etc/php.d/xcache.ini
echo -e "zend_extension=/usr/lib64/php/modules/xcache.so" >> /etc/php.d/xcache.ini
echo -e "[xcache.admin]" >> /etc/php.d/xcache.ini
echo -e "xcache.admin.enable_auth = Off" >> /etc/php.d/xcache.ini
echo -e "[xcache]" >> /etc/php.d/xcache.ini
echo -e "xcache.shm_scheme =        \"mmap\"" >> /etc/php.d/xcache.ini
echo -e "xcache.size  =               64M" >> /etc/php.d/xcache.ini
echo -e "xcache.count =                 1" >> /etc/php.d/xcache.ini
echo -e "xcache.slots =                8K" >> /etc/php.d/xcache.ini
echo -e "xcache.ttl   =                 0" >> /etc/php.d/xcache.ini
echo -e "xcache.gc_interval =           0" >> /etc/php.d/xcache.ini
echo -e "xcache.var_size  =            32M" >> /etc/php.d/xcache.ini
echo -e "xcache.var_count =             1" >> /etc/php.d/xcache.ini
echo -e "xcache.var_slots =            8K" >> /etc/php.d/xcache.ini
echo -e "xcache.var_ttl   =             0" >> /etc/php.d/xcache.ini
echo -e "xcache.var_maxttl   =          0" >> /etc/php.d/xcache.ini
echo -e "xcache.var_gc_interval =     300" >> /etc/php.d/xcache.ini
echo -e "xcache.readonly_protection = Off" >> /etc/php.d/xcache.ini
echo -e "xcache.mmap_path =    \"/dev/zero\"" >> /etc/php.d/xcache.ini
echo -e "xcache.coredump_directory =   \"\"" >> /etc/php.d/xcache.ini
echo -e "xcache.experimental =        Off" >> /etc/php.d/xcache.ini
echo -e "xcache.cacher =               On" >> /etc/php.d/xcache.ini
echo -e "xcache.stat   =               On" >> /etc/php.d/xcache.ini
echo -e "xcache.optimizer =           On" >> /etc/php.d/xcache.ini
echo -e "[xcache.coverager]" >> /etc/php.d/xcache.ini
echo -e "xcache.coverager =          Off" >> /etc/php.d/xcache.ini
echo -e "xcache.coveragedump_directory = \"\"" >> /etc/php.d/xcache.ini

# Check the admin page : http://localhost/xcache-admin/index.php
cp admin /var/www/xcache-admin -R



Tuesday, September 4, 2012

[Tutorial] How optimize images JPG/PNG/GIF on Linux using littleutils package centos 7.x

Littleutils package contains couple of little utils useful for production websites.
I've used the opt-png, opt-jpg, opt-gif to reduce and optimize the size of images on some high trafficed websites without any quality loss.

# Install pngcrush :
cd /usr/src
wget https://sourceforge.net/projects/pmt/files/pngcrush/1.8.10/pngcrush-1.8.10.tar.gz
tar -zxf pngcrush-1.8.10.tar.gz
cd pngcrush-1.8.10
chown -R nobody /usr/src/pngcrush-1.8.10
sudo -u nobody make
cp pngcrush /usr/local/bin

On CentOS 7 you can use : yum install pngcrush

yum install libpng-devel gifsicle lzip libjpeg-turbo-utils lzma imlib2-devel zlib-devel 
cd /usr/src
wget http://downloads.sourceforge.net/project/littleutils/littleutils-source/1.0.39/littleutils-1.0.39.tar.bz2
tar -jxf littleutils-1.0.39.tar.bz2
cd littleutils-1.0.39
./configure
chown -R nobody /usr/src/littleutils-1.0.39

sudo -u nobody make
make install
make install-extra


The following script first backup all images in the /home folder, then optimize each one :


#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
cd /home;
NOW=$(date +"%d-%m-%Y");
echo -e "Backup images ...\nBackup file : ./backup-pictures-$NOW.tar";
`find . -regextype posix-extended -iregex "(.*?)\.(gif|jpe?g|png)" -print | tar -cf backup-pictures-$NOW.tar -T -`;
echo "" > log;
echo -e "Backup size is :";
echo `du -hs ./backup-pictures-$NOW.tar`;
echo -e "\nStart optimizing images ...\nLog file: ./log"
pics=`find . -regextype posix-extended -iregex "(.*?)\.(gif|jpe?g|png)"`;
for pic in $pics; do
        type=`file "$pic" | awk '{print $2}' | tr '[:upper:]' '[:lower:]'`;
        case $type in
                        "gif" )
                                        opt-gif "$pic" >> log
                                        ;;
                        "png" )
                                        opt-png "$pic" >> log
                                        ;;
                        "jpeg" )
                                        opt-jpg "$pic" >> log
                                        ;;

                        *)
                                        echo -e "file $pic which has type $type is undefined" >> log

                                        ;;
        esac
done
IFS=$SAVEIFS

Sunday, August 5, 2012

Compile memcached latest version on linux

Recently I've compiled latest memcached version from source :

cd /usr/src
wget http://memcached.org/latest
tar -zxf memcached*
cd memcached*
./configure --prefix=/usr --sysconfdir=/etc
chown -R nobody /usr/src

sudo -u nobody make
make install

#Debian :
cp ./scripts/memcached-init /etc/init.d/memcached

wget vps5.in/files/memcached.conf -P /etc
mkdir -p /usr/share/memcached
cp -R scripts /usr/share/memcached


#centos :
cp ./scripts/memcached.sysv /etc/init.d/memcached
echo -e "PORT=11211\nUSER=nobody\nMAXCONN=1024\nCACHESIZE=64\nOPTIONS=\"\"" > /etc/sysconfig/memcached
mkdir -p /var/run/memcached
ln -s /etc/sysconfig/memcached /etc/memcached.conf
#
chmod a+x /etc/init.d/memcached
chkconfig memcached on

For php usage of memcached you'll need to compile php5-memcache pecl library.

I wanted to use memcached cache for some high-trafficed joomla 1.5 but I've found that joomla 1.5 cache is broken and all cache types are redirected to file caching ! So I'll upgrade to newer joomla versions in future and start using the power of memcached soon ...

How to Stream RTSP / Webcam / IP Camera Over the Web

I had a Hikvision IPC-B120 that provides a simple RTSP stream, which I could view in VLC. I also wanted to see my Logitech BRIO’s feed in a ...