Install pdflib and pdf.so in Plesk

21 10 2009

Download the pacakge, their official site is www.pdflib.com

root@server# wget http://www.pdflib.com/binaries/PDFlib/703/PDFlib-Lite-7.0.3.tar.gz
root@server#  tar xvzf PDFlib-Lite-7.0.3.tar.gz
root@server#  cd PDFlib-Lite-7.0.3
root@server#  ./configure --prefix=$HOME/usr --without-java
root@server#  make
root@server#  make install

install php-pear using

yum install php-pear


root@server#  pecl download pdflib
root@server#  tar xvzf pdflib-*.tgz
root@server#  cd pdflib-*
root@server#  phpize
root@server#  ./configure --with-pdflib=$HOME/usr
root@server#  make
root@server#  make test
make install

Add pdf.so in /etc/php.ini and restart httpd. You got it !!!




How to transfer sitebuilder data and user accounts to another Plesk server

20 10 2009

Source server :

take a back up of sites in /usr/local/sitebuilder/htdocs (in debian /opt/sitebuilder)

and move it to new server

scp -r /usr/local/sitebuilder/htdocs/sites/* root@targetserverip:/usr/local/sitebuilder/htdocs/sites/

correct the permissions as web server

chown apache.apache -R /usr/local/sitebuilder/htdocs/sites/  <new server >

After that we need to take sitebuilder backup

mysqldump -u admin -p`cat /etc/psa/.psa.shadow ` sitebuilder3 > sitebuilderback.sql

move it to new server using scp

After that restore the transferred sitebuilder dump in new server

mysql -u admin -p`cat /etc/psa/.psa.shadow ` sitebuilder3 < sitebuilderback.sql

After that login to the new server MySQL and select database sitebuilder3 and check the users using the command

select user_name from user where user_name not like ‘admin%’;

If you are seeing the users , you are DONE!!!





How to take domain database backup in plesk

11 10 2009

# cat domain_dump.sh
var_remote=’remote_ip_address’
mkdir /root/dump_temp/
mysql -u admin -p`cat /etc/psa/.psa.shadow ` -e “show databases” |grep -v “-” |grep -Ev ‘Database|information_schema’ >> /root/backuplist
for i in `cat /root/backuplist`;
do
echo “database is $i”
mysqldump -u admin -p`cat /etc/psa/.psa.shadow` $i > /root/dump_temp/$i.sql
echo “dump of $i created”
done
echo “Creating the tar file in /root”
cd /root
tar -cvzf /root/dump_`date +”%Y-%m-%d”`.tar.gz dump_temp/
lftp $var_remote<<EOF | sort>$TMPFILE
user “username” “password”
cd IP/directory
put dump_`date +”%Y-%m-%d”`.tar.gz
EOF
echo “Deleteing the backup files”
rm -rf /root/dump_temp
rm -rf /root/dump_`date +”%Y-%m-%d”`.tar.gz





Sqlite issue in Plesk ( Sitebuilder)

11 10 2009

Sqlite installed and updated.

  1. Download source package. You can get it from here: http://pecl.php.net/package/SQLite

# wget http://pecl.php.net/get/SQLite-1.0.3.tgz
or
# pear download sqlite

If publication host has x86_64 architecture it is suggested to use source files from here http://cvs.php.net/viewvc.cgi/pecl/sqlite/?pathrev=PHP_5_2 and make sure that SQLite library has version 2.8.17 or upper.

  1. Unpack SQLite-1.0.3.tgz to SQLite-1.0.3 directory:

# tar -xzf SQLite-1.0.3.tgz

  1. Move into SQLite-1.0.3 directory

# cd SQLite-1.0.3

  1. You need to have UTF-8 encoding support for sqlite.so extension, so following modification should be done:

edit SQLite-1.0.3/libsqlite/src/main.c file and change this section

#ifdef SQLITE_UTF8
const char sqlite_encoding[] = “UTF-8″;
#else
const char sqlite_encoding[] = “iso8859″;
#endif

to

//#ifdef SQLITE_UTF8
const char sqlite_encoding[] = “UTF-8″;
//#else
//const char sqlite_encoding[] = “iso8859″;
//#endif

comment all strings excluding one with UTF-8 encoding.

  1. Find phpize binary file and run it. Location for this file can be different. Standard path is /usr/bin/phpize. Make sure that you are still in SQLite-1.0.3 directory and run the following command:

# /usr/bin/phpize (path to phpize can be different)

If there is no such file, try to find it with following commands:

# whereis phpize
# locate phpize|grep bin

  1. Find location for php-config file. It should be the same as for phpize file and run following commands:

    # ./configure –with-sqlite –with-php-config=/usr/bin/php-config (path to php-config can be different)

  2. Run ‘make’ command:

# make

If you meet something like that:

“error: `BYREF_NONE’ undeclared”

you will need edit sqlite.c comment out the following line:

/* static unsigned char arg3_force_ref[] = {3, BYREF_NONE, BYREF_NONE, BYREF_FORCE }; */

And then change these lines

function_entry sqlite_functions[] = {
PHP_FE(sqlite_open, arg3_force_ref)
PHP_FE(sqlite_popen, arg3_force_ref)


to

function_entry sqlite_functions[] = {
PHP_FE(sqlite_open, third_arg_force_ref)
PHP_FE(sqlite_popen, third_arg_force_ref)

  1. # make
  2. # make install
  3. # cp modules/sqlite.so /usr/lib/php/modules (path to modules folder can be different). Actually, ‘make install’ should copy the extension to appropriate place so this operation might be not required.
  4. You should create a file in /etc/php.d/ named sqlite.ini or add sqlite.so extension directly into php.ini file. Inside write this :

    ; Enable sqlite extension module
    extension=sqlite.so
  5. Restart apache service with

# /sbin/service/httpd restart
or
# /etc/init.d/httpd restart





Update Plesk package using command line, for already created domains.

11 10 2009

echo “SELECT d.name FROM domains d , Limits L JOIN Limits L2 ON L2.id=L.id WHERE d.limits_id=L.id AND L.value=4194304000 AND L2.limit_name=’disk_space’ AND L2.value=52428800″| mysql -Ns -uadmin -p`cat /etc/psa/.psa.shadow` -Dpsa | while read domname ;

do

/usr/local/psa/bin/domain_pref –update $domname -disk_space 100M -max_traffic 8000M;

/usr/local/psa/bin/domain –update $domname -hard_quota 100M;

done

Using the above command/script we can update the package 50M/4GB bandwidth to 100MB/8GB

In the MySQL query you need to give the vale of 50M as bytes ie 50*1024*1024 and bandowth as 4000*1024*1024.





Hode in Plesk gives blank page after login

9 10 2009

If you are getting segmentaion fault/blank page for horde in plesk, you can check the following steps

1. Log in to the server shell.
2. Issue the following command:
# mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -e “replace into misc (param,val) values (’apache_pipelog’, ‘true’);”
3. Rebuild Apache configuration as follows:
# $PRODUCT_ROOT_D/admin/sbin/websrvmng -v -a





Installing memcached in Plesk

8 10 2009

Install libevent:

cd /usr/local/src
wget http://monkey.org/~provos/libevent-1.3e.tar.gz
tar -zxf libevent-1.3e.tar.gz
cd libevent-1.3e
./configure
make
make install

you may need to link /usr/local/lib/libevent to /usr/lib/libevent

wget http://danga.com/memcached/dist/memcached-1.2.4.tar.gz
tar zxvf memcached-1.2.4.tar.gz
cd memcached-1.2.4
./configure
make
make install

which memcached
/usr/local/bin/memcached -d
memcached -d -m 256 -u nobody -p 11211 -l 192.x.x.x (Server IP)

Enabling it in PHP

check zlib is installed in the server.

cd /usr/src
wget http://pecl.php.net/get/memcache-2.2.5.tgz
tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5
phpize
./configure
make
make install

==========================================

php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini

vi /usr/local/lib/php.ini

extension = “memcache.so”

save the file and restart httpd server.

/etc/init.d/httpd restart





Install memcached in a cPanel Server

15 08 2009
cd /usr/local/src
wget http://monkey.org/~provos/libevent-1.3e.tar.gz
tar -zxf libevent-1.3e.tar.gz
cd libevent-1.3e
./configure
make
make install

The output of “make install” is very important as it lets you know where the compiled module was installed. The default library location is
/usr/local/lib. Open the configuration file;

vi /etc/ld.so.conf.d/libevent.conf (add the entry ‘/usr/local/lib’ )
Check whether the libevent is completely installed.
ldconfig -v |grep libevent

Now you can install the “Memcache” module.

wget http://danga.com/memcached/dist/memcached-1.2.4.tar.gz
tar zxvf memcached-1.2.4.tar.gz
cd memcached-1.2.4
./configure
make
make install

Now you can check whether the Memcache module has properly installed.

which memcached
/usr/local/bin/memcached -d
memcached -d -m 256 -u nobody -p 11211 -l 192.x.x.x (Server IP)
ps -ax |grep memcached
netstat -plan |grep memcached




increase ulimit in CentOS

12 08 2009

by default the ulimit is set to 1024 only, first u need to increase system wise with

“fs.file-max = 65536″

adding this one in sysctl.conf

and then “sysctl -p”

switch to /etc/securitty/limits.conf and add ther following lines

* hard nofile 65536
* soft nofile 16384

switch 2 user for which u need to increase the file-max for, with this the default for all users will be 16384,

u can increase with ulimit -n XXXX now





Spam Tracking in Plesk qmail

12 08 2009

Install qmhandle-1.3.2 from:

http://downloads.sourceforge.net/sourceforge/qmhandle/qmhandle-1.3.2.tar.gz?use_mirror=nchc

cd qmhandle-1.3.2
./qmHandle -s
shows the stats of mails.

To view the mails in queue, please do

# /var/qmail/bin/qmail-qstat
messages in queue: 758
messages in queue but not yet preprocessed: 0

Let’s examine the queue with qmail-qread. Seeing a bunch of strange email addresses in the recipient list usually it’s meaning spam.

# /var/qmail/bin/qmail-qread

Please examine the email content of the emails in the queue using vi or cat  command. Firstly we should find message’s id using qmail-qread, then find the file holding the email in/var/qmail/queue with find command.

# find /var/qmail/queue/ -name (msg id)

Find the IP address from the mail header and remove spam from the queue using qmail-remove

Now, remove spams, they all will end up in the/var/qmail/queue/yanked directory :

# /etc/init.d/qmail stop

# qmail-remove -r -p ‘mail@address.com’

In a few minutes we do have more emails with the same patterns from the same ip address. That’s great, we do have opportunity to examine smtp traffic from the spammer’s ip address. Run tcpdumpand wait a few minutes.

# tcpdump -i eth0 -n src xxx.xxx.xxx.xxx \or dst xxx.xxx.xxx.xxx -w smtp.tcpdump -s 2048

Examining log file with vi we found that spammer is sending spam using LOGIN authentication:

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

220 ulise.domain.com ESMTP
ehlo User
250-ulise.domain.com
250-AUTH=LOGIN CRAM-MD5 PLAIN
250-AUTH LOGIN CRAM-MD5 PLAIN
250-STARTTLS
250-PIPELINING
250 8BITMIME
AUTH LOGIN
334 VXNlcm5hbWU6
dGVzdA==
334 UGFzc3dvcmQ6
MTIzNDU=
235 go ahead

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

Then decode the user/pass to see which account is used:

# perl -MMIME::Base64 -e ‘print decode_base64(”dGVzdA==”)’ test

# perl -MMIME::Base64 -e ‘print decode_base64(”MTIzNDU=”)’ 12345

So, someone created a test account with a weak password and someone else guessed it and is sending spam through the server.

Let’s find the domain owning of the mailbox:

[root@ulise ~]# mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa

mysql> SELECT m.mail_name, d.name, a.password FROM mail AS m LEFT JOIN (domains AS d, accounts AS a) ON (m.dom_id = d.id AND m.account_id = a.id) WHERE m.mail_name=’test’ AND a.password=’12345′;
+———–+————+———-+
| mail_name | name       | password |
+———–+————+———-+
| test      | example.com | 12345    |
+———–+————+———-+
1 row in set (0.01 sec)

Next step is to delete test mailbox and send a warning to client.

To improve your server’s security you’ll need to enable:
Server -> Mail -> Check the passwords for mailboxes in the dictionary

Reference : http://www.cherpec.com/2008/07/plesk-howto-debug-spam-problems/