Exim is a mail transfer agent (MTA) used on Unix-like operating systems.
To print a list of the messages in the queue:
# exim -bp
To remove all messages from the queue:
# exim -bp | exiqgrep -i | xargs exim -Mrm
Testing email with exim
# exim -v 'user@domain'
# message here
# ^D ( control D )
This will use exim from the command line to create an email message To: user@domain. After typing the message, use Control+D to send the EOF (end of file) characters to exim. Exim will stop receiving input from the command line and send the message text to user@domain.
How to limit the number of emails sent by each user (prevent spammer) with DA.
http://help.directadmin.com/item.php?id=81
Monday, 21 May 2012
Wednesday, 9 May 2012
Fix Apache – No space left on device: Couldn’t create accept lock
This issue is related to semaphores. To view how many semaphores you have use:
root@hal [~]# sysctl -a | egrep kernel.sem\|kernel.msgmni
kernel.sem = 250 32000 32 128
kernel.msgmni = 16
You can change this values by adding them in /etc/sysctl.conf and then using sysctl -p to activate them.
There is no need to reboot.
There is no need to reboot.
To remove sempahores use either one of these commands:
for i in `ipcs -s | grep nobody | awk ‘{print $2}’`; do ipcrm -s $i; done
/scripts/restartsrv_httpd
or in Perl
ipcs -s | grep nobody | perl -e ‘while () { @a=split(/\s+/); print `ipcrm sem $a[1]`}’
or with xargs
ipcs -s | grep nobody | awk ‘ { print $2 } ‘ | xargs ipcrm
or bash style
for ipsemId in $(ipcs -s | grep nobody | cut -f 2 -d ‘ ‘); do ipcrm $ipsemId;done
Other errors :
Cannot create SSLMutex
add in httpd.conf
SSLMutex sem
Tuesday, 8 May 2012
Nginx + php 5.2.17 + php-fpm
Download the needed packages and store them in /usr/src:
http://us.php.net/distributions/php-5.2.17.tar.gz
http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
http://nginx.org/download/nginx-1.1.0.tar.gz
Then run :
tar -xvzf php-5.2.17.tar.gz
gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | sudo patch -d php-5.2.17 -p1
cd php-5.2.17
./configure --enable-fastcgi --enable-fpm --with-mcrypt --with-zlib --enable-mbstring --enable-pdo --with-curl --disable-debug --with-pic --disable-rpath --enable-inline-optimization --with-bz2 --enable-xml --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --with-xsl --enable-zip --with-pcre-regex --with-gd --without-pdo-sqlite --with-pdo-mysql --without-sqlite --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-mysql --enable-bcmath --enable-calendar --enable-exif --enable-ftp --with-gettext --with-imap --with-mysqli --with-openssl --with-kerberos --with-imap-ssl --enable-dbase --with-gmp --enable-shmop --enable-wddx
make all install
Note that you can add –prefix to install the binaries in a different location than the default one.
After compilation is done :
strip /usr/local/bin/php-cgi
cp sapi/cgi/fpm/php-fpm /etc/init.d/
chmod +x /etc/init.d/php-fpm
cp /usr/src/php-5.2.17/php.ini-recommended /usr/local/lib/php.ini
mkdir /etc/php/
ln -s /usr/local/lib/php.ini /etc/php/php.ini
ln -s /usr/local/etc/php-fpm.conf /etc/php/php-fpm.conf
Make sure you edit /etc/php/php-fpm.conf and set the proper user/group (and permissions if its the case).
Then compile Nginx:
tar zxvf nginx-1.1.0.tar.gz
./configure --sbin-path=/usr/local/sbin --with-http_ssl_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module
make && sudo make install
The same you can modify the –prefix here.
Script to autorestart httpd server if it fails
I use this script on a cpanel server..if output of pgrep command is 0 then the $restart command is issued
#!/bin/bash
restart=”/scripts/restartsrv_httpd”
pgrep httpd || $restart
exit 0
If its a VPS then I might add to clear the Semaphore Arrays.
for i in `ipcs -s | grep nobody | awk ‘{print $2}’`; do ipcrm -s $i; done
Then I put this script into Cron to run every 5 minutes.
# MIN HOUR DAYOFMONTH MONTH DAYOFWEEK COMMAND
*/5 * * * * /root/checkhttp.sh
Monitoring users with last and lastb
Probably all of you know already about the ”last” command and what it outputs.
For example here is what my says:
[aibo@lap ~]$ last | more giani pts/2 :0.0 Tue Oct 14 21:45 still logged in giani pts/6 :0.0 Tue Oct 14 21:06 still logged in abo pts/5 :pts/3:S.1 Tue Oct 14 21:06 still logged in abo pts/4 :pts/3:S.0 Tue Oct 14 21:05 still logged in abo pts/3 lap.x83.net Tue Oct 14 21:05 still logged in
It very important to choose strong passwords for all accounts, especially root, since it is the #1 attacked account.
Also an other nice tools is ”’lastb”’ which shows the last failed logins.
Top 5 most recently attacked accounts [root@lap ~]# lastb | awk '{print $1}' | sort | uniq -c | sort -rn | head -5 7 root 2 rancid 2 giany 1 btmp 1
Top 5 most attacked accounts [root@lap ~]# awk 'gsub(".*sshd.*Failed password for (invalid user )?", "") {print $1}' /var/log/secure* | sort | uniq -c | sort -rn | head -5 144 root 30 test 18 admin 9 user 6 webmaster
Top 5 attacker IP addresses [root@lap ~]# awk 'gsub(".*sshd.*Failed password for (invalid user )?", "") {print $3}' /var/log/secure* | sort | uniq -c | sort -rn | head -5 397 124.109.44.155 128 206.169.122.212 107 89.179.174.40 24 83.17.92.138 15 85.25.151.96
Repair a Mysql database
When we try to repair a MySQL database we can stop the service. If you are using the MyISAM engine I recommend using myisamchk. A basic repair sentence could be like this:
myisamchk -r -q -p -v –sort_buffer_size=2000M /var/lib/mysql/database/table.MYI
The used parameters are the following:
* -r recovery mode
* -q quick recovery, the most common one. If this mode does not work you will have to make some research on your own.
* -p creates the keys to be repared in parallel threads.
* -v verbose mode
* –sort_buffer_size= use this to indicate the size of the buffer to sort the keys. If you do not specify this value, or the value you specify is too small, then you will see something like this myisamchk: error: myisam_sort_buffer_size is too small. To solve this just increment the size of the buffer to be used, if the error always appear then you have a extremely big table.
* -q quick recovery, the most common one. If this mode does not work you will have to make some research on your own.
* -p creates the keys to be repared in parallel threads.
* -v verbose mode
* –sort_buffer_size= use this to indicate the size of the buffer to sort the keys. If you do not specify this value, or the value you specify is too small, then you will see something like this myisamchk: error: myisam_sort_buffer_size is too small. To solve this just increment the size of the buffer to be used, if the error always appear then you have a extremely big table.
Subscribe to:
Posts (Atom)