Plesk FTP account passwords

May 5th, 2011 No comments

Open phpMyAdmin or mysql command line client, choose database pma and execute query:

USE psa;
SELECT REPLACE( sys_users.home, '/var/www/vhosts/', '' ) AS domain, sys_users.login, accounts.password
FROM sys_users
LEFT JOIN accounts ON sys_users.account_id = accounts.id
ORDER BY sys_users.home ASC

It will show you all FTP users from Plesk

Categories: MySQL, Plesk Tags: , , ,

Linux upgrade from i386/i686 to x86_64

April 1st, 2011 1 comment

This article describes upgrade CentOS 5.5 from i386 arch to x86_64 arch.

First of all, upgrade kernel and boot loader from CD. For my system this operation was done by hosting provider.

After kernel upgrade system have a lot of i386/i686 packages. It isn’t possible to upgrade each package manually. For example, my CentOS had 300+ packages.

To continue you need to install yum

The algorithm of upgrading is simple:

  1. install for each i386/i686 package its x86_64 analogue
  2. erase i386/i686 packages

But it can be complicated, because any packages uses the same paths or something else and you need manually to install RPMs.

Let’s begin.

Install yum plugin yum-downloadonly:

yum install yum-allowdowngrade

Then take a list of packages for upgrade:

rpm -qa --qf "%{name}.%{arch}\n" | grep -E "i386|i686"

Copy this list into your text editor and replace “.i386” and “.i686” with “.x86_64”. Also replace all returns with spaces. You will take something like this:

glibc.x86_64 readline.x86_64 ncurses.x86_64

Now download this packages RPMs:

yum install --downloadonly --downloaddir=/root/rpms/ <packages>

where <packages> are in my example glibc.x86_64 readline.x86_64 ncurses.x86_64

Of course directory/root/rpms/ must exist.

When yum finishes to download hundreds of packets, chdir to /root/rpms/ and execute

rpm -i --force *.rpm

rpm will force installation of all downloaded packages.

After installation you need come back to your i386/i686 packages list and uninstall them.

yum erase <packages>

where <packages> are in my example glibc.i686 readline.i386 ncurses.i386

That’s all!

Categories: Linux, Plesk Tags: , ,

Parallels Plesk license key location

March 22nd, 2011 No comments

Plesk license key is located:

1. Parallels Panel 7.x – 8.x:
/etc/psa/psa.key

2. Parallels Panel 9+:
/etc/sw/keys/keys/key*

Categories: Plesk Tags: ,

Proftpd passive mode hangs or works slow

February 9th, 2011 No comments

There is 2 steps.

First of all, add to /etc/proftpd.include followed code:

TimeoutIdle                 900
TimeoutNoTransfer           900
PassivePorts                49152 65534
TimesGMT                    Off

Then test the iptables nat helper:

modprobe ip_conntrack_ftp

If there is no errors, add to directive IPTABLES_MODULES in /etc/sysconfig/iptables-config module ip_conntrack_ftp:

IPTABLES_MODULES="ip_conntrack_ftp"

If you need to load two or more helpers, separate them with spaces because the iptables script does a for-in on the IPTABLES_MODULES directive.

Categories: Linux, Plesk Tags: , , , ,

Plesk: Premature end of script headers OR cgi_wrapper target uid/gid mismatch (500 Internal server error)

January 24th, 2011 1 comment

When you have a newly installed Plesk, it’s not enought to run PHP-scripts in CGI. Unfortunately.

You need manually copy suexec file from Plesk binaries file folder to system binaries folder.

In common cases it does command:

# cp /usr/local/psa/suexec/psa-suexec /usr/sbin/suexec

If cp cannot find any of files, search they manually

# locate suexec

Important! It’s recommended to make a copy of system’s suexec file

# cp /usr/sbin/suexec /usr/sbin/suexec_old
Categories: Linux, Plesk Tags: , , , ,

Parallels small business panel. How to disable mail for domain

December 19th, 2010 1 comment

I’ve needed to allow for my domain only hosting without mail service. Mail server will be remote. I’ve changed MX-records to remote server IP (or hostname), but it’s not enough. Also this domain must be removed from mail daemon (Qmail, Postfix or other) config files.

There is no possibility to disable mail service for domain via Small business panel. You can only do it via command line.

#/usr/local/psa/bin/domain -u <domain> -mail_service false

Additionally, if you want to set option “What to do with mail sent to nonexistent users” to “Forward to address”, you need than manually edit

/var/spool/postfix/plesk/virtual.db

with command

postmap -d @<domain> hash:virtual
Categories: Mail, Plesk Tags: ,

Plesk AWStats view statistics for all domain

June 8th, 2010 No comments

By default in Plesk you can view AWstats statistics for each domain separately at http://<yourdomain>/webstat . And you must type here FTP password for the domain. It’s not comfortably when your server holds much more than one domain.

So, our task is to create superadmin-access for AWStats for viewing all domains statistics with only one password.

First of all, find you awstats.pl file. It must be located in cgi-bin directory which lies near your vhosts. In my case it’s /srv/www/cgi-bin

Put here 2 files:

.htaccess:

AuthUserFile /srv/www/cgi-bin/.htpasswd
AuthName "AWStats"
AuthType Basic
require valid-user

index.pl:

#!/usr/bin/perl

use strict;
use warnings;

use CGI qw(:standard);

print header;
print start_html(-title => 'AWStats');

opendir (DIRH, '/usr/local/psa/etc/awstats') || die; # path depends on your system

print '<div align="center">';

my $file; my @files;
# awstats config files are named like awstats.<yourdomain>-http.conf
# if you need to see also ftp etc, modify my code
while ($file = readdir DIRH) {
 $_ = $file; # my perl doesn't works without assignment result of readdir
 next unless m/\-http\.conf$/;
 push @files, $file;
}

for $file (sort @files) {
 $_ = $file;
 s/^awstats\.//;
 s/\.conf//;
 print "<a target='_blank' href='awstats.pl?config=",$_,"'>";
 s/\-http//;
 print;
 print '</a><br>';
}

print "</div>";

Don’t forget to chmod +x index.pl

To finish with this dir, create .hpasswd file:

htpasswd -c .htpasswd <username>

At last you need to config Apache web-server.

Put in /etc/apache2/conf.d/awstats.conf (or create a new one):

ScriptAlias /awstats-full /srv/www/cgi-bin
Alias  /awstats-icon /usr/share/apache2/icons/awstats

<Directory /srv/www/cgi-bin>
 AllowOverride All
</Directory>

Please check all paths, they are depend on your system. For exampe, apache config dir may be /etc/httpd/

Finally, restart Apache graceful (recommended)

apachectl -k graceful

or restart fully

apachectl -k restart

Now you can see all domain statistics on http://<your ip>/awstats-full/index.pl

Categories: Linux, Plesk Tags: , , , ,

MySQL backup databases into separate files by weekdays with compression

May 15th, 2010 No comments

I’ve found in Net script, which only backups databases into separate files and modified it. I’ve added gzip compression and backup by weekday. So, you can cron this job daily and get backups for each weekday. It’s very flexible backup algorithm.

Script is below:

#!/bin/bash

# This script backups every MySQL database to its own file

#Some variables you can set how you like
USER='<possible root>'
PASSWORD='<password>'
DAYOFWEEK=`/bin/date +"%w"`
OUTPUTDIR="/usr/backup/mysql/$DAYOFWEEK" # backup dir
MYSQLDUMP='/usr/local/bin/mysqldump'     # path to mysqldump, may be /usr/bin/mysqldump
MYSQL='/usr/local/bin/mysql'             # path to mysql, may be /usr/bin/mysql  

#Clean up any old backups
rm -f $OUTPUTDIR/*

#Get a list of databases names except the system one
databases=`$MYSQL --user=$USER --password=$PASSWORD -e 'SHOW DATABASES;' | grep -Ev '(Database|information_schema)'`

#Dump each database in turn and compress the output with gzip
for db in $databases; do
$MYSQLDUMP --opt --hex-blob --force --user=$USER --password=$PASSWORD $db | gzip > $OUTPUTDIR/$db.gz
done

Download script mysql_backup.sh (800 kB)

Categories: Linux, MySQL Tags: , ,

PHP get Google backlinks for domain/site

February 20th, 2010 No comments

Function below allow you to get count of Google backlinks for requested page

function getGoogleOuterLinksCount($url) {
 $domain = preg_replace('/^www\./','',array_shift(split('/',$url)));

 /*  I strongly recommend you to use www.google.<you country zone> version of Google */
 $html = "http://www.google.com/search?q=link:".$domain."&hl=en"; 

 $content = getRemoteFile($html);
 if (preg_match('/<div id=resultStats>(\d+) results/i',$content,$arr)) {
   $t = $arr[1];
   $t = str_replace(' ','',$t);
   $t = str_replace(',','',$t);
   return (int)$t;
 } else
   return 0;
}

function getRemoteFile($url) {
   $ch = curl_init($url);
   curl_setopt($ch, CURLOPT_HEADER, 1);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

   $data = curl_exec($ch);

   if(curl_errno($ch)) {
      echo "Error!  Error code:".curl_errno($ch)." Error:".curl_error($ch);
      curl_close($ch);
      return false;
   }

   list($header, $data) = preg_split("/\r?\n\r?\n/", $data, 2);

   return $data;
}
Categories: PHP Tags: ,

PHP get Google index for domain/site. Indexed by Google pages count

February 19th, 2010 1 comment

The function below allow you to get the count of pages indexed by Google.

function getGoogleIndexCount($url) {
   $html = "http://www.google.com/search?hl=en&safe=off&q=site%3A".$url."&btnG=Search"; // I strongly recommend you to use www.google.<you country zone> version of Google

   $content = getRemoteFile($html);
   if (preg_match('/<div id=resultStats>(\d+) results/i',$content,$arr)) {
       $t = $arr[1];
       $t = str_replace(' ','',$t);
       $t = str_replace(',','',$t);
       return (int)$t;
   } else return 0;
}

function getRemoteFile($url) {
   $ch = curl_init($url);
   curl_setopt($ch, CURLOPT_HEADER, 1);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

   $data = curl_exec($ch);

   if(curl_errno($ch)) {
      echo "Error!  Error code:".curl_errno($ch)." Error:".curl_error($ch);
      curl_close($ch);
      return false;
   }

   list($header, $data) = preg_split("/\r?\n\r?\n/", $data, 2);

   return $data;
}
Categories: PHP Tags: ,