More than 3 years have passed since last update.

posted at

updated at


Amazon Linux 2にClamAVをインストールする

clamd.scanはかなりメモリを食うのでt2.microでは動かなかった。t2.mediumでは動いた。topで見たところ、VIRTが800 MiB、RESが600 MiBほど使っていた。


sudo amazon-linux-extras install -y epel
sudo yum install -y clamav clamav-update clamd


当方では何も編集せずともsudo freshclamは動いた。


sudo freshclam


/etc/cron.d/clamav-updateというファイルが既に存在し、中で/usr/bin/freshclam --quietを実行しているので、ウィルス定義の更新は毎日自動で実行される。



--- scan.conf.orig  2019-01-05 02:44:58.000000000 +0900
+++ scan.conf   2019-03-05 12:00:08.489123891 +0900
@@ -5,13 +5,13 @@

 # Comment or remove the line below.

 # Uncomment this option to enable logging.
 # LogFile must be writable for the user running daemon.
 # A full path is required.
 # Default: disabled
-#LogFile /var/log/clamd.scan
+LogFile /var/log/clamd.scan

 # By default the log file is locked for writing - the lock protects against
 # running clamd multiple times (if want to run another clamd, please
@@ -90,7 +90,7 @@

 # Path to a local socket file the daemon will listen on.
 # Default: disabled (must be specified by a user)
-#LocalSocket /var/run/clamd.scan/clamd.sock
+LocalSocket /var/run/clamd.scan/clamd.sock

 # Sets the group ownership on the unix socket.
 # Default: disabled (the primary group of the user running clamd)
@@ -98,7 +98,7 @@

 # Sets the permissions on the unix socket to the specified mode.
 # Default: disabled (socket is world accessible)
-#LocalSocketMode 660
+LocalSocketMode 660

 # Remove stale socket after unclean shutdown.
 # Default: yes
@@ -174,8 +174,8 @@
 # Don't scan files and directories matching regex
 # This directive can be used multiple times
 # Default: scan all
-#ExcludePath ^/proc/
-#ExcludePath ^/sys/
+ExcludePath ^/proc/
+ExcludePath ^/sys/

 # Maximum depth directories are scanned at.
 # Default: 15
@@ -204,7 +204,7 @@

 # Run as another user (clamd must be started by root for this option to work)
 # Default: don't drop privileges
-User clamscan
+#User clamscan

 # Stop daemon when libclamav reports out of memory condition.
 #ExitOnOOM yes


sudo systemctl start clamd@scan
sudo systemctl enable clamd@scan

ログはjournalctl -u clamd@scanで見る。

あとは普通にsystemctl status clamd@scan systemctl stop clamd@scanができる。


下記はいずれもAmazon Linux 1だったり、yumのパッケージ内容が変わっていたり?だったりして、そのままでは動かなかった。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up