Thursday, March 7, 2013

FTP failed on plesk server


On a plesk server I could not connect to ftp so when I checked the logs I found

- warning: unable to determine IP address of ‘myhostname.server.com’
- error: no valid servers configured
- Fatal: error processing configuration file '/etc/proftpd.conf'
Then, I checked the /etc/hosts and found hostname entry missing:

[root]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
So to get this fixed I added the below entry in the /etc/hosts file

xx.xx.xx.xx myhostname.server.com
And, then restarted xinetd which fixed the issue.

How to install qmHandle on plesk server ?


Install qmHandle on plesk dedicated server using the below steps:

Login to the sever as root.

Download the tar from here using the following command:

root# wget
http://jaist.dl.sourceforge.net/sourceforge/qmhandle/qmhandle-1.3.2.tar.gz
root# tar -zxvf qmhandle-1.3.2.tar.gz
root# chmod 755 qmHandle
root# ./qmHandle –h
Few commands of qmhandle :

List help for qmhandle commands.

qmHandle -h
Show statistics for qmail mail queue

qmHandle -s
Deliver all mails in mail queue.

qmHandle -a
This article is released by SupportFacility.Com — the leaders in providing outsourced technical support, live chat support & help desk support for web hosts. Interested ? Opt for a trial now.

Plesk : Configure qmail to use alternate SMTP port 26


You have a plesk dedicated server and having issues related to SMTP port 25. There are issues where ISP blocks SMTP port 25, in this case we can use alternate port (I will use port 26).
Kindly follow the below steps to change SMTP port on your plesk dedicated (linux) server to 26.

Login to your server as root

root# cd /etc/xinetd.d
root# ls -l | grep smtp*
root# cat smtp_psa
service smtp
{
socket_type = stream
protocol = tcp
wait = no
disable = no
user = root
instances = UNLIMITED
server = /var/qmail/bin/tcp-env
server_args = /usr/sbin/rblsmtpd -r bl.spamcop.net /var/qmail/bin/relaylock /var/qmail/bin/qmail-smtpd /var/qmail/bin/smtp_auth /var/qmail/bin/true /var/qmail/bin/cmd5checkpw /var/qmail/bin/true
}
root# nano /etc/services
Add the below lines

smtp_psa_new 26/tcp mail
smtp_psa_new 26/udp mail
root# cp smtp_psa smtp_psa_new
Change the service line in the new file “smtp_psa_new” to be this:

service smtp_psa_new
{
socket_type = stream
protocol = tcp
wait = no
disable = no
user = root
instances = UNLIMITED
server = /var/qmail/bin/tcp-env
server_args = /usr/sbin/rblsmtpd -r bl.spamcop.net /var/qmail/bin/relaylock /var/qmail/bin/qmail-smtpd /var/qmail/bin/smtp_auth /var/qmail/bin/true /var/qmail/bin/cmd5checkpw /var/qmail/bin/true
}
root# /etc/init.d/xinetd restart
And you should see smtp listening on ports 25, and 26:

root# netstat -anp | grep xinetd
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 6989/xinetd
tcp 0 0 0.0.0.0:26 0.0.0.0:* LISTEN 6989/xinetd
That’s it!

Plesk configuration files path + linux?


Guys,

Here are the paths :

Plesk Config & Binary file

Linux :

===============================================
# Plesk tree
PRODUCT_ROOT_D - /usr/local/psa
===============================================
# Directory of SysV-like Plesk initscripts
PRODUCT_RC_D - /etc/init.d

/etc/psa/psa.conf // common config file
/etc/psa/.psa.shadow // admin password file
/var/log // common log file
/etc/local/psa/admin/logs //plesk log file
================================================

# Directory for config files
PRODUCT_ETC_D - /usr/local/psa/etc
================================================

# Virtual hosts directory
HTTPD_VHOSTS_D - /var/www/vhosts
/var/www/vhosts//anon_ftp , cgi-bin, conf, error_docs , httpdocs, httpsdocs , pd , private , statistics-->/logs(domain logs), subdomains , web

Domain based httpd.conf file:- /var/www/vhosts/conf/httpd.include
Doc root : /var/www/vhosts//httpdocs
===============================================

# Apache configuration files directory
HTTPD_CONF_D - /etc/httpd/conf/httpd.conf //server based
/var/www/vhosts/conf/httpd.include // domain based

------------------------------------------------
# Apache include files directory
HTTPD_INCLUDE_D - /etc/httpd/conf.d/mailman.conf , perl.conf, python.conf , webalizer.conf, zz010_psa_httpd.conf, fcgid.conf, manual.conf , php.conf, ssl.conf, welcome.conf
------------------------------------------------
# Apache binary files directory
HTTPD_BIN_D - /usr/bin
------------------------------------------------
#Apache log files directory
HTTPD_LOG_D - /var/log/httpd
------------------------------------------------
#apache startup script
HTTPD_SERVICE httpd
/etc/init.d/httpd [start|stop|restart|status]


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

# Qmail directory
QMAIL_ROOT_D /var/qmail

# Location of qmail maildirs
QMAIL_MAILNAMES_D /var/qmail/mailnames/
/var/qmail/mailnames//mail a/c/Maildir/new,cur,tmp

# Path to rblsmtpd
RBLSMTPD /usr/sbin/rblsmtpd

# Courier-IMAP
COURIER_IMAP_ROOT_D /

/etc/init.d/qmail [status,start,stop,restart] //service control

================================================
# Proftpd
FTPD_CONF /etc/proftpd.conf
FTPD_CONF_INC /etc/proftpd.include
FTPD_BIN_D /usr/bin
FTPD_VAR_D /var/run/proftpd
FTPD_SCOREBOARD /var/run/proftpd/scoreboard

Log file :- /var/log/xferlog
Service control :- /etc/init.d/proftpd [start,stop,status,restart]
================================================
# Bind
NAMED_RUN_ROOT_D /var/named/run-root/etc/named.conf
/var/named/run-root/var/ // db record

Service control :- /etc/init.d/named [status,start,stop,restart]
log:- /var/log/messages
===============================================

# Webalizer
WEB_STAT /usr/bin/webalizer
===============================================
# Logrotate
LOGROTATE /usr/local/psa/logrotate/sbin/logrotate
===============================================
# MySQL
MYSQL_VAR_D /var/lib/mysql
MYSQL_BIN_D /usr/bin

Service control:- /etc/rc.d/init.d /mysqld [start,stop,restart,status]
log :- /var/log/messages
===============================================
# PostgreSQL
PGSQL_DATA_D /var/lib/pgsql/data
PGSQL_BIN_D /usr/bin
===============================================
# Backups directory
DUMP_D /var/lib/psa/dumps
===============================================
# Mailman directories
MAILMAN_ROOT_D /usr/lib/mailman
MAILMAN_VAR_D /var/lib/mailman
===============================================
# Python binary
PYTHON_BIN /usr/bin/python2.3

# Tomcat root directory
CATALINA_HOME /usr/share/tomcat5

# DrWeb
DRWEB_ROOT_D /opt/drweb
DRWEB_ETC_D /etc/drweb

# GnuPG binary
GPG_BIN /usr/bin/gpg

# Tar binary
TAR_BIN /bin/tar
===============================================
# Curl certificates
CURL_CA_BUNDLE_FILE /usr/share/curl/curl-ca-bundle.crt
=========================================================
# AWStats
AWSTATS_ETC_D /etc/awstats
AWSTATS_BIN_D /var/www/cgi-bin/awstats
AWSTATS_TOOLS_D /usr/share/awstats
AWSTATS_DOC_D /var/www/html/awstats
===============================================
# openssl binary
OPENSSL_BIN /usr/bin/openssl

LIB_SSL_PATH /lib/libssl.so
LIB_CRYPTO_PATH /lib/libcrypto.so

CLIENT_PHP_BIN /usr/local/psa/bin/php-cli
--------------------------------------------------
Psa Spammasion:-
/usr/local/psa/admin/bin/spamd --status
--stop
--start
--------------------------------------------------

qmail configuration in Plesk


qmail is the MTA used in plesk servers

Log file location: /usr/local/psa/var/log/maillog

How do I repair Qmail configuration


# /usr/local/psa/admin/sbin/mchk --help
Synopsis:
mchk [OPTION]
--without-spam - restore all settings except for SpamAssassin configuration
--with-spam - restore all settings
--spam-only - restore only SpamAssassin settings

eg: # /usr/local/psa/admin/sbin/mchk --with-spam


Managing a QMail queue

/var/qmail/bin/qmail-showctl will show info about qmail setup.

/var/qmail/bin/qmail-qstat will show what is in the mail queue.

# to clear the queue
{
/etc/init.d/qmail stop
cd /var/qmail/queue
rm -rf info intd local mess remote todo
mkdir mess
for i in `seq 0 22`; do
mkdir mess/$i
done
cp -r mess info
cp -r mess intd
cp -r mess local
cp -r mess remote
cp -r mess todo
chmod -R 750 mess todo
chown -R qmailq:qmail mess todo
chmod -R 700 info intd local remote
chown -R qmailq:qmail intd
chown -R qmails:qmail info local remote
/etc/init.d/qmail start
}

qmHandle
qmHandle is a handy tool for manipulating the qmail queue, and for gathering some basic statistics about it.

To install it (to your current directory) run:


wget -O - "http://easynews.dl.sourceforge.net/sourceforge/qmhandle/qmhandle-1.3.2.tar.gz" | tar xzf -
If you're using qmHandle with Plesk's qmail, try an older version that doesn't attempt to stop qmail with 'svc':


wget -O - "http://easynews.dl.sourceforge.net/sourceforge/qmhandle/qmhandle-1.2.0.tar.gz" | tar xzf -
If you have a lot of bounce notices sitting in your queue, try running:


./qmHandle -S'failure notice'
The -S means ' delete all messages that have/contain text as Subject'.

Need to track who sent an email?
Need to track who sent a particular email from your server? e.g. if a user account is compromised and you need to see which user account?

The email will have headers like:


Received: (qmail 13711 invoked from network); 26 Jun 2007 02:55:46 -0000
Received: from hpbizway.com.ar (HELO User) (1.2.3.4)
by example.com with SMTP; 26 Jun 2007 02:55:46 -0000
The 'invoked from network' means the email was received from an external host (e.g. it was not send from a program like apache on your server itself).

The IP that sent the email was 1.2.3.4

So run:


grep 1.2.3.4 /var/log/messages
(Use whatever IP you need to there).

And you will find which user that IP was using. e.g.


/var/log/messages:Jun 26 16:17:35 example smtp_auth: SMTP connect from unknown@hpbizway.com.ar [1.2.3.4]
/var/log/messages:Jun 26 16:17:35 example smtp_auth: smtp_auth: SMTP user claudia
In this case it is the 'claudia' user. And a suitable follow up would be to, say, change the password on that user account.

QMail maxing out the CPU
Do you have lots of /var/qmail/bin/qmail-smtpd processes? All using lots of CPU?

Are you missing files named /var/qmail/control/dh512.pem and /var/qmail/control/dh1024.pem?

Do you have /var/qmail/control/dhparams512.pem and /var/qmail/control/dhparams1024.pem?

In this case it may be that your qmail process is generating a ssl key for each connection, rather than using a pre-prepared one.

The fix is to run:


cp /var/qmail/control/dhparams512.pem /var/qmail/control/dh512.pem
cp /var/qmail/control/dhparams1024.pem /var/qmail/control/dh1024.pem
Then you may also need to restart xinetd with

/etc/init.d/xinetd restart

Tuesday, March 5, 2013

Configure Apache to listen multiple ports


The listen directive in the Apache configuration file can be used to make Apache to listen in a particular port or IP address or port combination.

Listen 80
Listen 8000

In this format the Apache server listens on the given ports on all interfaces (IP addresses) which are up in the server. If you mention the above two directives in the Apache configuration file then the Apache server will listen on both the ports 80 and 8000. Multiple Listen directives may be used to specify a number of addresses and ports to listen to.

Listen IP:80

You need to replace the IP address in this example with the IP address you want the Apache service to listen. In this format an IP address is given as well as a port. In this case the server will listen on the given port and interface( IP address ). If you want the Apache service to listen on two IP addresses in the server you can use multiple listen directive in the configuration file.

Listen IP1:80
Listen IP2:80

Please remember to restart the Apache service in the server once the changes are made to the configuration file.

Starting Apache HTTPD Failed Cannot Open or No such file mod_bwlimited, mod_log_bytes or mod_bandwidth


On restaring Apache, you may get the following error:

Nov 21 09:31:40 web httpd: Cannot load usr/local/apache/libexec/mod_log_bytes.so into server: /usr/local/apache/libexec/mod_log_bytes.so: cannot open shared object file: No such file or directory
Nov 21 09:31:40 web rc: Starting httpd: failed

Invalid command ‘BytesLog’, perhaps mis-spelled or defined by a module not included in the server configuration

This is most likely due to the cause that the mod_belimited.so, mod_log_bytes.so, or mod_bandwidth.so are deleted or corrupted. These 3 files are unique on cPanel based servers.

This error is received when the Apache HTTPD server has been messed up with some shared library files such as mod_auth_passthrough.so, mod_bwlimited.so and mod_log_bytes.so located in libexec directory, that have accidentally been deleted or corrupted.

The solution to the error is to recompile those shared library modules. You can easily compile these cPanel modules for Apache by using the following commands:

cd /usr/local/cpanel/apache

/usr/local/apache/bin/apxs -iac mod_log_bytes.c

/usr/local/apache/bin/apxs -iac mod_bwlimited.c

/usr/local/apache/bin/apxs -iac mod_bandwidth.c

After compilation, the .so files will automatically be copied to libexec directory for Apache HTTPD web server.