Archive

Archive for the ‘Linux’ Category

PHP based torrent file creator, tracker and seed server – PHPTracker

September 16th, 2011 Comments off

Great software!

Why PHPTracker? Because it’s not “just a tracker”, it contains a seeder server too so the distribution of your files is automatic. This is a big step for the content providers to adapt this amazing technology and change the stereotype that “torrent = warez”.

PHP based torrent file creator, tracker and seed server – PHPTracker.

Categories: Linux, MySQL, PHP Tags: , , ,

Plesk: Real memory usage reported by ‘Server Health’ does not match actual RAM

August 29th, 2011 Comments off

Symptoms
Real memory usage reported by Plesk Health Monitoring Service (Home > Server Health > Memory) does not match RAM reported by utility ‘free‘.

Cause
RAM was updated after Parallels Plesk Panel was installed.
Plesk Health Monitor does not detect if the system configuration was changed after the initial installation.

Resolution
The problem will be fixed in future update of Parallels Plesk Panel that will be released after version 10.2.

To workaround:

# /usr/local/psa/bin/sw-engine-pleskrun /usr/local/psa/admin/plib/scripts/setup-health-monitor.php
Categories: Linux, Plesk Tags: , ,

ffmpeg-php – error: ‘PIX_FMT_RGBA32’ undeclared (first use in this function)

August 24th, 2011 Comments off

ffmpeg-php – error: ‘PIX_FMT_RGBA32’ undeclared (first use in this function) | HOW GEEK!.

/root/install/ffmpeg-php-0.6.0/ffmpeg_frame.c: In function 'zim_ffmpeg_frame_toGDImage':
/root/install/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: 'PIX_FMT_RGBA32' undeclared (first use in this function)
/root/install/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: (Each undeclared identifier is reported only once
/root/install/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: for each function it appears in.)
/root/install/ffmpeg-php-0.6.0/ffmpeg_frame.c: In function 'zim_ffmpeg_frame_ffmpeg_frame':
/root/install/ffmpeg-php-0.6.0/ffmpeg_frame.c:421: error: 'PIX_FMT_RGBA32' undeclared (first use in this function)
make: *** [ffmpeg_frame.lo] Error 1

To fix this, replace PIX_FMT_RGBA32 with PIX_FMT_RGB32 .

You can use “rpl” to replace files recursively:

cd to the ffmpeg-php folder and run this command (beware!):

rpl -R PIX_FMT_RGBA32 PIX_FMT_RGB32 *

If rpl not installed on your system, install it, for example:

yum install rpl
Categories: Linux, PHP 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: , ,

Proftpd passive mode hangs or works slow

February 9th, 2011 Comments off

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: , , , ,

Plesk AWStats view statistics for all domain

June 8th, 2010 Comments off

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 Comments off

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: , ,

Manage Services/Daemons in Fedora Core, CentOS, FreeBSD, Debian, Ubuntu

January 25th, 2010 Comments off

I introduce you my small manual for Linux Administrators how in most popular Linux-family OS config your services/daemons with comfortable tools.

Manage Services/Daemons in Fedora Core / CentOS / Red Hat

After you have created your own service, placed it in /etc/init.d/ dir, you need to set the runlevel for it.

To control services either use

chkconfig

or

ntsysv

if you are using the command line, or use

system-config-services

in the GUI. Gnome users: System > Administration > Server Settings > Services.

Manage Services/Daemons in Debian / Ubuntu

For Debian I recommend you to use sysvconfig package.

To install do the following:

apt-get install sysvconfig

Enjoy!

Manage Services/Daemons in FreeBSD

Unfortunately, in FreeBSD there is no such comfortable utility to manage services. You need do edit
/etc/rc.conf manually.

Categories: Linux Tags: ,

Plesk: RewriteRule to redirect from subdomains mail, ftp, ns1, ns2 to main domain

November 11th, 2009 Comments off

By default in Plesk the is such interesting configuration. When you try to access virtual subdomain, for example mail.domain.com or ftp.domain.com, via HTTP, in browser you see the last added in Plesk domain!

To fix it you’ll need to write additional Apache .conf file:

<VirtualHost <ip1>:80 <ip2>:80 <ip3>:80>
 ServerName mail
 ServerAlias mail.*
 ServerAlias ns1.*
 ServerAlias ns2.*
 ServerAlias ftp.*

 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^(?:www\.)?(?:ftp|mail|ns1|ns2)\.(.*)$ [NC]
 RewriteRule ^(.*) http://%1$1 [L,R]

</VirtualHost>

<IfModule mod_ssl.c>
<VirtualHost  <ip1>:443 <ip2>:443 <ip3>:443>
 ServerName mail
 ServerAlias mail.*
 ServerAlias ns1.*
 ServerAlias ns2.*
 ServerAlias ftp.*

 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^(?:www\.)?(?:ftp|mail|ns1|ns2)\.(.*)$ [NC]
 RewriteRule ^(.*) https://%1$1 [L,R]

</VirtualHost>
</IfModule>

Name this file subdomains_redirect.conf and place it to /etc/httpd/conf.d or /etc/apache2/conf.d

Download subdomains_redirect.conf (590 bytes)

Categories: Linux Tags: ,