LibClamAV Warning: *** The virus database is older than 7 days! ***

If you are getting this error message, you probably haven’t updated default config file yet.

~# nano /etc/freshclam.conf

You need to comment the Example line – this is the usual mistake people forget, it’s rarely mentioned in google discussions ..

# Comment or remove the line below.
Example

change to

# Comment or remove the line below.
# Example

Next uncomment these 2 lines

DatabaseDirectory /var/lib/clamav
UpdateLogFile /var/log/freshclam.log

And run freshclam. That will update the database.

~# /usr/bin/freshclam
ClamAV update process started at Wed Jan 11 08:24:05 2017
main.cvd is up to date (version: 57, sigs: 4218790, f-level: 60, builder: amishhammer)
daily.cvd is up to date (version: 22872, sigs: 1320094, f-level: 63, builder: neo)
bytecode.cld is up to date (version: 285, sigs: 57, f-level: 63, builder: bbaker)

It’s best to set up cron job that runs this update for you, e.g.

15      1       *       *       *       /usr/bin/freshclam

rsync between servers – how to filter by file extension

If you need to rsync some files over network, this is the command

rsync -c -az -ersync -c -e 'ssh -p 2020' --stats --progress --whole-file jan@myserver.com:data/files/ ~/data/files/

Script will connect to myserver.com on port 2020 and copy files from my home directory to local home directory.
If you want to access folder outside of your home directory, just add a slash after .com:

Filter by file extension

~# rsync -c -az -ersync -c -e 'ssh -p 2020' --stats --progress --whole-file --include="*/" --include='*.gif' --exclude="*" jan@myserver.com:data/files/ ~/data/files/

This will copy gifs only.
Always remember to combine exclude and include together – if you omit exclude parameter, your –include won’t have any affect.

Fastest rsync to copy millions of files between servers

rsync -a -e 'ssh -p 2020' --stats --whole-file jan@myserver.com:data/files/. ~/data/files

It doesn’t compress the file, doesn’t look for checksum difference, basically it just looks if file exists on new server – if it doesn’t copy it. Uses very little cpu and it skips building of file list

Plesk 17.x courier-imaps: Maximum connection limit reached for IP

Imagine you got 5 people in the office and IMAP randomly fails for some people, you are unable to receive or send emails and Apple Mail gives you a vague error “Verify that the username and password are correct”.

Chances are you are hitting the PERIP limit.
Take a look at /var/log/maillog, look for these errors:

Jan 1 12:41:34 109 courier-imapd: Maximum connection limit reached for ::ffff:XXX.XXX.XXX.XXX
Jan 1 12:41:34 109 courier-imapd: Maximum connection limit reached for ::ffff:XXX.XXX.XXX.XXX

Edit these 2 files
/etc/courier-imap/imapd
/etc/courier-imap/imapd-ssl

Edit both of them, you need to change these 2 lines in the first one, and add to the -ssl version:

MAXDAEMONS = 160
MAXPERIP = 120

You can make the same changes in /etc/courier-imap/pop3d and pop3d-ssl

You need to restart imap service for these settings to take affect, on regular centos you run

~# systemctl restart courier-imap

but if you are running Plesk, the service won’t even exist, instead you need to do

~# /usr/local/psa/admin/sbin/mailmng --restart-service

CentOS 7 – stdatomic.h: No such file or directory

I got this error while installing Mplayer on Centos7.
This is the full error

libavutil/atomic.h:32:7: warning: "HAVE_ATOMICS_SUNCC" is not defined [-Wundef]
 #elif HAVE_ATOMICS_SUNCC
       ^
CC	libavutil/camellia.o
CC	libavutil/cast5.o
CC	libavutil/channel_layout.o
CC	libavutil/color_utils.o
CC	libavutil/cpu.o
libavutil/cpu.c:20:23: fatal error: stdatomic.h: No such file or directory
 #include 
                       ^
compilation terminated.
make[1]: *** [libavutil/cpu.o] Error 1
make[1]: Leaving directory `/root/mplayer/ffmpeg'
make: *** [ffmpeg/libavutil/libavutil.a] Error 2

Basically you have 2 options, 1/ upgrade gcc to 4.9 ( very long process ), or 2/ download stdatomic.h and add it into the package you’re installing. You definitely want to go with option no.2

Go here https://gist.github.com/nhatminhle/5181506 and download the file ( you get link in upper right corner – hit Raw button ).
And then look where is it used in the package you are installing

root@lj: mplayer# pwd
/root/mplayer

root@lj: mplayer# wget https://gist.githubusercontent.com/nhatminhle/5181506/raw/541482dbc61862bba8a156edaae57faa2995d791/stdatomic.h

root@lj: mplayer# find ./ -name "*.c" | xargs grep "stdatomic" -n
./ffmpeg/compat/atomics/pthread/stdatomic.c:27:#include "stdatomic.h"
./ffmpeg/libavutil/cpu.c:20:#include 

Open stdatomic.c on line 27 and cpu.c on line 20 and make following change, from

#include 

to

//#include 
#include 

That’s it – this is by far the easiest way to deal with this error.

CentOS7 httpd permission denied for write, even with 777 permission

CentOS can be real pain when it comes to permissions.
Even if you set 777 to a folder you still won’t be able to write to it in Apache.
You need to enable it on system level as well:

chcon -R -t httpd_sys_rw_content_t /var/www/vhosts/localhost/httpdocs/files/
chcon -R -t httpd_sys_content_t /var/www/vhosts/localhost/httpdocs/files/
chcon -R -t httpd_sys_content_rw_t /var/www/vhosts/localhost/httpdocs/files/

Now Apache will be able to write to /var/www/vhosts/localhost/httpdocs/files/ and all subfolders.