11
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2019-03-05

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

freshclamの設定ファイルを編集

/etc/freshclam.confを必要に応じて編集する。
当方では何も編集せずともsudo freshclamは動いた。

freshclamを実行してみる(ウィルス定義の更新)

sudo freshclam

cronの設定の確認

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

clamdの設定ファイルを編集

編集しないと起動しなかった。

/etc/clamd.d/scan.conf
--- 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.
-Example
+#Example

 # 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

clamdの起動

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

ログはjournalctl -u clamd@scanで見る。
設定ファイルで設定してあれば/var/log/clamd.scanにも出る。

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

参考

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

11
8
0

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
  3. You can use dark theme
What you can do with signing up
11
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?