Entries Tagged 'Linux' ↓

Plesk rebuild Apache configuration files

Sometimes you need to rebuild all your httpd.include files, it can be done with websrvmng command:

/usr/local/psa/admin/bin/websrvmng -av

Rename command

Rename it’s handy command from util-linux package when you need to rename multiple files. From the manual:

NAME
       rename - Rename files
SYNOPSIS
       rename from to file...
DESCRIPTION
       rename will rename the specified files
       by replacing the first occurrence of
       from in their name by to.
...

Example usage:

[vitalie@silver london]$ ls -1
DSC00967.JPG
DSC00968.JPG
DSC00969.JPG
DSC00970.JPG
DSC00971.JPG
[vitalie@silver london]$ rename DSC00 london_ *.JPG
[vitalie@silver london]$ ls -1
london_967.JPG
london_968.JPG
london_969.JPG
london_970.JPG
london_971.JPG

Bind restricting recursion

If your server allows recursive queries it can be exploited by malicious users. It should be restricted only to ip addresses from your local nets.

To accomplish this, edit your /etc/named.conf and specify in “options” section which ACL are allowed to run recursive queries with allow-recursion option:

# /etc/named.conf
acl localnets { 127.0.0.1; 192.168.0.0/24; };
 
options {
...
allow-recursion { localnets; };
...
};

then restart bind server:

[root@red ~]# /etc/init.d/named restart
Stopping named: .                     [  OK  ]
Starting named:                       [  OK  ]

In Plesk it can be done from the Control Panel:
Server->DNS Settings->DNS Preferences->Allow recursion
and choose localhost or localnets.

How to disable IPv6 in RHEL, Fedora, CentOS

Open your /etc/modprobe.conf file and append:

# Turn off IPv6
alias net-pf-10 off
alias ipv6 off

Then restart your server.

Lame servers messages

Lame server is when a NS record for a domain specifies a server which is not authoritative for that domain.

To keep your logs clean from lame server messages (/var/log/messages):

[...]
Nov 16 15:10:50 srv named[99]: lame server resolving 'abc.com' (in 'abc.com'?): 1.2.3.4#53
Nov 16 15:10:50 srv named[99]: lame server resolving 'abc.com' (in 'abc.com'?): 1.2.3.4#53
Nov 16 15:10:50 srv named[99]: lame server resolving 'abc.com' (in 'abc.com'?): 1.2.3.4#53
Nov 16 15:10:50 srv named[99]: lame server resolving 'abc.com' (in 'abc.com'?): 1.2.3.4#53
Nov 16 19:43:25 srv named[99]: lame server resolving 'abc.com' (in 'abc.com'?): 1.2.3.4#53
Nov 16 19:43:25 srv named[99]: lame server resolving 'abc.com' (in 'abc.com'?): 1.2.3.4#53
[...]

Edit your /etc/named.conf and add:

logging {
  category lame-servers { null; };
};

Then restart bind daemon.

Howto enable antivirus for all accounts in Plesk

To enable AntiVirus for all accounts in Plesk you can use the following script:

#!/bin/bash
 
mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa<<-EOT
UPDATE mail 
  SET virusfilter = 'any'
  WHERE postbox = 'true' AND virusfilter != 'any'
EOT

You can run it daily from the cron to keep your mailboxes protected.

Nagios check_mailq: is not executable by uid 0

If you receive this error then your plugin needs patching:

ERROR:  is not executable by (uid 0:gid(0 10 6 4 3 2 1 0))

The patch:

--- /usr/lib/nagios/plugins/check_mailq 2007-04-20 23:14:48.000000000 +0300
+++ check_mailq 2007-06-04 11:53:06.000000000 +0300
@@ -40,7 +40,7 @@
 sub print_usage ();
 sub process_arguments ();
 
-$ENV{'PATH'}='';
+$ENV{'PATH'}='/bin:/usr/bin';
 $ENV{'BASH_ENV'}='';
 $ENV{'ENV'}='';
 $PROGNAME = "check_mailq";
@@ -49,6 +49,9 @@
 $msg_p = 0 ;
 $state = $ERRORS{'UNKNOWN'};
 
+# 
+$utils::PATH_TO_QMAIL_QSTAT = "/var/qmail/bin/qmail-qstat";
+
 Getopt::Long::Configure('bundling');
 $status = process_arguments();
 if ($status){
@@ -63,7 +66,6 @@
 alarm($opt_t);
 
 # switch based on MTA
-
 if ($mailq eq "sendmail") {
 
        ## open mailq

Plesk password recovery

If you forgot your admin password in Plesk, you’ll need to connect to your server with ssh and you can find the password in the file /etc/psa/.psa.shadow .

[root@apollo ~]# cat /etc/psa/.psa.shadow
<admin_pass>

To find mailbox’s password in Plesk, connect to your server with ssh, then use the following SQL query to reveal mailbox password (replace MAILBOX_NAME with your mailbox name):

[root@apollo ~]# mysql -u admin -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='MAILBOX_NAME'

Howto install RMagick on CentOS 4

RMagick is an interface between the Ruby programming language and the ImageMagick® and GraphicsMagick image processing libraries.

To install RMagick on CentOS 4 you’ll need to install RMagick version 1 because version 2 requires newer version of ImageMagick that’s not available in CentOS 4 repositories.

I do assume that you already have installed RubyGems. If not, then read my post Install RubyGems on CentOS 4.

Let’s start by installing required libraries:

[root@lion ~]# yum  install gcc gcc-c++ ImageMagick-devel ghostscript freetype-devel \ 
                         libjpeg-devel libpng-devel libpng10-devel libwmf-devel libexif-devel libtiff-devel
[...]

Then install RMagick gem specifying version with ‘-v’ switch:

[root@lion ~]# gem install rmagick -v 1.15.14 
Building native extensions.  This could take a while...
Successfully installed rmagick-1.15.14
1 gem installed

Using squirrelmail in Plesk

Configuring apache for squirrelmail following this tutorial is not enough. You’ll need to configure squirrelmail too. Edit your /etc/squirrelmail/config_local.php file and paste the following configuration:

// courier-imap settings
$imap_server_type       = 'courier';
$default_folder_prefix  = 'INBOX.';
$trash_folder           = 'Trash';
$sent_folder            = 'Sent';
$draft_folder           = 'Drafts';
$show_prefix_option     = false;
$default_sub_of_inbox   = false;
$show_contain_subfolders_option = false;
$optional_delimiter     = '.';
$delete_folder          = true;
$force_username_lowercase = false;
 
// other settings
$default_charset        = 'iso-8859-1';
$lossy_encoding         = false;
$sendmail_args          = '-i -t';
$encode_header_key      = '';
$hide_auth_header       = false;
$plugins[3] = 'filters';
$abook_global_file = '';
$abook_global_file_writeable = false;
 
$addrbook_global_dsn = '';
$addrbook_global_table = 'global_abook';
$addrbook_global_writeable = false;
$addrbook_global_listing = false;