суббота, 21 августа 2010 г.

debian lenny xen XENBUS: Waiting for devices to initialise...

В Lenny бажный tap:aio
Лечится так

ln -s /usr/lib/xen-3.2-1/bin/tapdisk /usr/sbin
echo xenblktap >> /etc/modules
modprobe xenblktap
/etc/init.d/xend restart

четверг, 19 августа 2010 г.

screen

Ctrl-a q
Send a start signal (associated with Ctrl-q by terminals) to current window. (xon)

Ctrl-a s
Send a stop signal (associated with Ctrl-s by terminals) to current window. (xoff)

Ctrl-a Z
Reset virtual terminal to its "power-on" values. (reset)

http://www.oreillynet.com/linux/cmd/cmd.csp?path=s/screen

вторник, 17 августа 2010 г.

perl file tests

Getting File Information

You can test certain features very quickly within Perl using a series of test operators known collectively as -X tests.

For example, to perform a quick test of the various permissions on a file, you might use a script like this:

#/usr/bin/perl


my (@description,$size);
if (-e $file)
{
push @description, 'binary' if (-B _);
push @description, 'a socket' if (-S _);
push @description, 'a text file' if (-T _);
push @description, 'a block special file' if (-b _);
push @description, 'a character special file' if (-c _);
push @description, 'a directory' if (-d _);
push @description, 'executable' if (-x _);
push @description, (($size = -s _)) ? "$size bytes" : 'empty';
print "$file is ", join(', ',@description),"\n";
}
Here is the list of features which you can check for a file

Operator Description
-A Age of file (at script startup) in days since modification.
-B Is it a binary file?
-C Age of file (at script startup) in days since modification.
-M Age of file (at script startup) in days since modification.
-O Is the file owned by the real user ID?
-R Is the file readable by the real user ID or real group?
-S Is the file a socket?
-T Is it a text file?
-W Is the file writable by the real user ID or real group?
-X Is the file executable by the real user ID or real group?
-b Is it a block special file?
-c Is it a character special file?
-d Is the file a directory?
-e Does the file exist?
-f Is it a plain file?
-g Does the file have the setgid bit set?
-k Does the file have the sticky bit set?
-l Is the file a symbolic link?
-o Is the file owned by the effective user ID?
-p Is the file a named pipe?
-r Is the file readable by the effective user or group ID?
-s Returns the size of the file, zero size = empty file.
-t Is the filehandle opened by a TTY (terminal)?
-u Does the file have the setuid bit set?
-w Is the file writable by the effective user or group ID?
-x Is the file executable by the effective user or group ID?
-z Is the file size zero?

http://www.tutorialspoint.com/perl/perl_files.htm

установка magickwand for php на debian

в системе уже должны быть установлены следующие пакеты
imagemagick
libmagic1
libmagick10
libmagick9-dev
php5-dev

Качаем http://www.magickwand.org/download/php/MagickWandForPHP-1.0.7.tar.gz
1.0.8 на lenny не соберется, т.к. ей требуется более свежий imagemagick

wget http://www.magickwand.org/download/php/MagickWandForPHP-1.0.7.tar.gz
tar -xzvf MagickWandForPHP-1.0.7.tar.gz
cd ./MagickWandForPHP-1.0.7/
phpize
ln -s /usr/bin/Wand-config /usr/bin/MagickWand-config
./configure
sed -i 's/-lMagickWand//g' Makefile
sed -i 's/-lMagickCore//g' Makefile
make
make install

vi /etc/php5/conf.d/magickwand.ini
[magickwand]
extension="magickwand.so"

локальная установка модулей php

Имеется хостинг сервер debian linux с панелью ispmanager и php в режиме fastcgi
Требуется установить расширение php для определенного пользователя, не затрагивая при этом глобальную конфигурацию.

Рассмотрим пример с пользователем default и расширением ssh2

cd /var/www/default/data/
sudo -u default -s
mkdir src
cd src
wget http://pecl.php.net/get/ssh2-0.11.0.tgz
tar -xzvf ssh2-0.11.0.tgz
cd ssh2-0.11.0
phpize
./configure
make
mkdir /var/www/default/data/php-bin/ext
cp modules/ssh2.so /var/www/default/data/php-bin/ext/

cd /var/www/default/data/php-bin
vi php.ini

[ssh2]
extension_dir=/var/www/default/data/php-bin/ext
extension="ssh2.so"

выполняем
php -m -c /var/www/default/data/php-bin/php.ini | less
и ищем там ssh2
на warning'и не обращаем внимания

php -i -c /var/www/default/data/php-bin/php.ini | less
и видим

ssh2

SSH2 support => enabled
extension version => 0.11.0-dev
libssh2 version => 0.18
banner => SSH-2.0-libssh2_0.18
remote forwarding => enabled
hostbased auth => enabled
polling support => enabled
publickey subsystem => enabled

Правда при этом ломаются все остальные модули, т.к. extension_dir не может содержать более одного значения

понедельник, 16 августа 2010 г.

apache2 mod_vhost_limit

Restrict the number of simultaneous connections per vhost

sources http://sisyphus.ru/en/srpm/Sisyphus/apache2-mod_vhost_limit/sources

Install

tar -xzvf mod_vhost_limit-0.2.tgz
cd mod_vhost_limit-0.2/
apxs2 -i -c -n mod_vhost_limit.so mod_vhost_limit.c

vi httpd.conf
LoadModule vhost_limit_module modules/mod_vhost_limit.so

ExtendedStatus On
MaxVhostClients 30

Save and restart apache

In apache error.log

[Tue Aug 17 02:17:46 2010] [warn] Vhost Limit : Access to domain.com deferred, Max Clients 10 exceeded (11 currently)
[Tue Aug 17 02:18:55 2010] [warn] Vhost Limit : Access to domain.com deferred, Max Clients 10 exceeded (13 currently)
[Tue Aug 17 02:18:55 2010] [warn] Vhost Limit : Access to domain.com deferred, Max Clients 10 exceeded (12 currently)

mod_slotlimit

http://sourceforge.net/projects/mod-slotlimit/

Модуль для организации ограничений для защиты от излишнего потребления ресурсов в системах массового хостинга. Возможно определить процент от общего объема обращений к apache, которое не может превысить один сайт (например, чтобы каждый сайт не мог потребить больше 15% общих ресурсов). Также позволяет определить максимальное число одновременных коннектов или число одновременных обращений от одного IP для каждого сайта.

PS.
Код ужасен. Радует то что его мало.
Можно написать свой, максимально коротко и ясно.

воскресенье, 15 августа 2010 г.

PHP 5.2.10 и выше конфликтует с Zend Optimizer до версии 3.3.3 включительно

PHP 5.2.10 и выше конфликтует с Zend Optimizer до версии 3.3.3 включительно.
Использование PHP 5.2.10 и выше возможно с Zend Optimizer версии 3.3.4/3.3.9 и выше.

http://www.hostcms.ru/forums/22/2992/

суббота, 14 августа 2010 г.

perl generate random string

sub generate_random_string
{
my $length_of_randomstring=shift;# the length of
# the random string to generate

my @chars=('a'..'z','A'..'Z','0'..'9','_');
my $random_string;
foreach (1..$length_of_randomstring)
{
# rand @chars will generate a random
# number between 0 and scalar @chars
$random_string.=$chars[rand @chars];
}

return $random_string;
}

print generate_random_string(14);