{"id":1038,"date":"2019-03-31T19:48:00","date_gmt":"2019-03-31T19:48:00","guid":{"rendered":"http:\/\/orissawebhosting.in\/blog\/?p=1038"},"modified":"2019-04-01T14:26:30","modified_gmt":"2019-04-01T14:26:30","slug":"installing-clamav-in-centos7","status":"publish","type":"post","link":"https:\/\/orissawebhosting.in\/blog\/installing-clamav-in-centos7\/","title":{"rendered":"How to Install ClamAV in CentOS7"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"> ClamAV is a free, open source antivirus program for the detection of trojans, viruses and malware on your VPS. In this tutorial we show you how to install ClamAV in CentOS 7 and how to ensure that ClamAV starts automatically and your VPS scans daily. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> Execute the commands in this article as a root user.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing_clamav\">Installing ClamAV<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Connect to your VPS via SSH and update your VPS first:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yum -y update<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\n\nClamAV is not included in the official CentOS package repository. It is included in the Extra Packages for Enterprise Linux (EPEL). Therefore, first install the latest release of EPEL\n\n<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yum -y install epel-release<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\n\nNext install ClamAV with the command (please note: there is a scroll bar because it is a long command):\n\n<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yum -y install clamav-server clamav-data clamav-update clamav-filesystem clamav clamav-scanner-systemd clamav-devel clamav-lib clamav-server-systemd\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"configuring_clamav\">Configuring ClamAV<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"> CentOS 7 is supplied with SELinux. Check whether SELinux is enabled with the command below. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sestatus<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\n\nIf the SELinux status is&nbsp;<strong>&#8216;disabled&#8217;<\/strong>, proceed to&nbsp;<strong>&#8216;<a href=\"https:\/\/www.transip.eu\/knowledgebase\/entry\/700-installing-clamav-in-centos7\/#2\">Step 2<\/a>&#8216;<\/strong>. If the SELinux status is&nbsp;<strong>&#8216;enabled&#8217;<\/strong>, give ClamAV access to all your files with the following command:\n\n<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">setsebool -P antivirus_can_scan_system 1 <br>setsebool -P clamd_use_jit 1<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"> ClamAV is supplied with a standard configuration file. A small adjustment is needed in this file before you can use it. The word example needs to be uncommented or removed from scan\/conf:&nbsp; <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sed -i -e \"s\/^Example\/#Example\/\" \/etc\/clamd.d\/scan.conf<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\n\nOpen the configuration file \/etc\/clamd.d\/scan.conf:&nbsp;\n\n<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vi \/etc\/clamd.d\/scan.conf<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\n\nUncomment\/remove the&nbsp;<strong>#<\/strong>&nbsp;at &#8216;<strong>#LocalSocket \/var\/run\/clamd.scan\/clamd.sock<\/strong>&#8216; so the line looks like this:&nbsp;\n\n<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">LocalSocket \/var\/run\/clamd.scan\/clamd.sock<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"> Save the changes and close the file (<strong>ctrl<\/strong>&nbsp;+&nbsp;<strong>x<\/strong>&gt;&nbsp;<strong>y<\/strong>&gt;&nbsp;<strong>enter<\/strong>). Without this step, the scanning service will not work.&nbsp; <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\n\nBefore you can use the scan service, Freshclam needs to be enabled and configured. Freshclam updates the database that ClamAV uses with virus definitions (the database is empty in a new installation). Again remove \/ uncomment&nbsp;<strong>&#8216;Example&#8217;<\/strong>&nbsp;from the configuration file.&nbsp;\n\n<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sed -i -e \"s\/^Example\/#Example\/\" \/etc\/freshclam.conf<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\n\nRun Freshclam with the command below. Freshclam will then immediately download the latest virus definitions.\n\n<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>freshclam<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\n\nNext you create a systemd service so ClamAV is automatically started and executed:&nbsp;\n\n<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vi \/usr\/lib\/systemd\/system\/freshclam.service<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\n\nAdd the following content and save the changes with&nbsp;<strong>ctrl<\/strong>&nbsp;+&nbsp;<strong>x<\/strong>&gt;&nbsp;<strong>y<\/strong>&gt;&nbsp;<strong>enter<\/strong>.\n\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">[Unit]<br> Description = freshclam scanner<br> After = network.target<br>[Service]<br> Type = forking<br> ExecStart = \/usr\/bin\/freshclam -d -c 1<br> Restart = on-failure<br> PrivateTmp =true <br>[Install]<br> WantedBy=multi-user.target <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\n\nChange the number 1 behind ExecStart to 2 if necessary, or another number to have the scan carried out more than once a day.\n\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\n\nThe virus definitions are now up-to-date. Enable autostart for the ClamAV scan service and freshclam, and start both services as follows:&nbsp;\n\n<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl enable clamd@scan <br>systemctl enable freshclam <br>systemctl start clamd@scan <br>systemctl start freshclam<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\n\nThe installation of ClamAV is now complete!&nbsp;\n\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ClamAV is a free, open source antivirus program for the detection of trojans, viruses and malware on your VPS. In this tutorial we show you how to install ClamAV in CentOS 7 and how to ensure that ClamAV starts automatically and your VPS scans daily. Execute the commands in this article as a root user. Installing ClamAV Connect to your VPS via SSH and update your VPS first: ClamAV is not included in the official CentOS package repository. It is included in the Extra Packages for Enterprise Linux (EPEL). Therefore,&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1038","post","type-post","status-publish","format-standard","hentry","category-categorized"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/1038","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/comments?post=1038"}],"version-history":[{"count":0,"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/1038\/revisions"}],"wp:attachment":[{"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/media?parent=1038"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/categories?post=1038"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/tags?post=1038"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}