{"id":2850,"date":"2015-12-16T16:47:50","date_gmt":"2015-12-16T16:47:50","guid":{"rendered":"https:\/\/qbytes.cloud\/?p=2850"},"modified":"2015-12-16T16:47:50","modified_gmt":"2015-12-16T16:47:50","slug":"install-clamav-on-centos-7","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2015\/12\/16\/install-clamav-on-centos-7\/","title":{"rendered":"Install ClamAV on CentOS 7"},"content":{"rendered":"<p>Install ClamAV and set up scheduled scans.<\/p>\n<p>Install Epel:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# yum install epel-release\n<\/pre>\n<p>Install ClmAV<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# yum install clamav-server clamav-data clamav-update clamav-filesystem clamav clamav-scanner-systemd clamav-devel clamav-lib clamav-server-systemd\nLoaded plugins: fastestmirror\nLoading mirror speeds from cached hostfile\n * base: mirror.lax.hugeserver.com\n * epel: dl.fedoraproject.org\n * extras: dallas.tx.mirror.xygenhosting.com\n * updates: linux.mirrors.es.net\nPackage clamav-data-0.98.7-1.el7.noarch already installed and latest version\nPackage clamav-filesystem-0.98.7-1.el7.noarch already installed and latest version\nPackage clamav-lib-0.98.7-1.el7.x86_64 already installed and latest version\nResolving Dependencies\n--&gt; Running transaction check\n---&gt; Package clamav.x86_64 0:0.98.7-1.el7 will be installed\n---&gt; Package clamav-devel.x86_64 0:0.98.7-1.el7 will be installed\n---&gt; Package clamav-scanner-systemd.noarch 0:0.98.7-1.el7 will be installed\n--&gt; Processing Dependency: clamav-scanner = 0.98.7-1.el7 for package: clamav-scanner-systemd-0.98.7-1.el7.noarch\n---&gt; Package clamav-server.x86_64 0:0.98.7-1.el7 will be installed\n--&gt; Processing Dependency: nc for package: clamav-server-0.98.7-1.el7.x86_64\n---&gt; Package clamav-server-systemd.noarch 0:0.98.7-1.el7 will be installed\n---&gt; Package clamav-update.x86_64 0:0.98.7-1.el7 will be installed\n--&gt; Running transaction check\n---&gt; Package clamav-scanner.noarch 0:0.98.7-1.el7 will be installed\n---&gt; Package nmap-ncat.x86_64 2:6.40-7.el7 will be installed\n--&gt; Finished Dependency Resolution\n\nDependencies Resolved\n\n===================================================================================================================================================================================================\n Package                                                   Arch                                      Version                                         Repository                               Size\n===================================================================================================================================================================================================\nInstalling:\n clamav                                                    x86_64                                    0.98.7-1.el7                                    epel                                    806 k\n clamav-devel                                              x86_64                                    0.98.7-1.el7                                    epel                                     37 k\n clamav-scanner-systemd                                    noarch                                    0.98.7-1.el7                                    epel                                     19 k\n clamav-server                                             x86_64                                    0.98.7-1.el7                                    epel                                     93 k\n clamav-server-systemd                                     noarch                                    0.98.7-1.el7                                    epel                                     19 k\n clamav-update                                             x86_64                                    0.98.7-1.el7                                    epel                                     89 k\nInstalling for dependencies:\n clamav-scanner                                            noarch                                    0.98.7-1.el7                                    epel                                     26 k\n nmap-ncat                                                 x86_64                                    2:6.40-7.el7                                    base                                    201 k\n\nTransaction Summary\n===================================================================================================================================================================================================\nInstall  6 Packages (+2 Dependent packages)\n\nTotal download size: 1.3 M\nInstalled size: 3.0 M\nIs this ok &#x5B;y\/d\/N]: y\nDownloading packages:\n(1\/8): clamav-0.98.7-1.el7.x86_64.rpm                                                                                                                                       | 806 kB  00:00:00\n(2\/8): clamav-devel-0.98.7-1.el7.x86_64.rpm                                                                                                                                 |  37 kB  00:00:00\n(3\/8): clamav-scanner-0.98.7-1.el7.noarch.rpm                                                                                                                               |  26 kB  00:00:00\n(4\/8): clamav-scanner-systemd-0.98.7-1.el7.noarch.rpm                                                                                                                       |  19 kB  00:00:00\n(5\/8): clamav-server-0.98.7-1.el7.x86_64.rpm                                                                                                                                |  93 kB  00:00:00\n(6\/8): clamav-server-systemd-0.98.7-1.el7.noarch.rpm                                                                                                                        |  19 kB  00:00:00\n(7\/8): clamav-update-0.98.7-1.el7.x86_64.rpm                                                                                                                                |  89 kB  00:00:00\n(8\/8): nmap-ncat-6.40-7.el7.x86_64.rpm                                                                                                                                      | 201 kB  00:00:00\n---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\nTotal                                                                                                                                                              1.3 MB\/s | 1.3 MB  00:00:00\nRunning transaction check\nRunning transaction test\nTransaction test succeeded\nRunning transaction\n  Installing : 2:nmap-ncat-6.40-7.el7.x86_64                                                                                                                                                   1\/8\n  Installing : clamav-server-0.98.7-1.el7.x86_64                                                                                                                                               2\/8\n  Installing : clamav-server-systemd-0.98.7-1.el7.noarch                                                                                                                                       3\/8\n  Installing : clamav-scanner-0.98.7-1.el7.noarch                                                                                                                                              4\/8\n  Installing : clamav-scanner-systemd-0.98.7-1.el7.noarch                                                                                                                                      5\/8\n  Installing : clamav-0.98.7-1.el7.x86_64                                                                                                                                                      6\/8\n  Installing : clamav-update-0.98.7-1.el7.x86_64                                                                                                                                               7\/8\n  Installing : clamav-devel-0.98.7-1.el7.x86_64                                                                                                                                                8\/8\n  Verifying  : clamav-scanner-systemd-0.98.7-1.el7.noarch                                                                                                                                      1\/8\n  Verifying  : clamav-server-0.98.7-1.el7.x86_64                                                                                                                                               2\/8\n  Verifying  : clamav-scanner-0.98.7-1.el7.noarch                                                                                                                                              3\/8\n  Verifying  : clamav-devel-0.98.7-1.el7.x86_64                                                                                                                                                4\/8\n  Verifying  : clamav-server-systemd-0.98.7-1.el7.noarch                                                                                                                                       5\/8\n  Verifying  : clamav-update-0.98.7-1.el7.x86_64                                                                                                                                               6\/8\n  Verifying  : 2:nmap-ncat-6.40-7.el7.x86_64                                                                                                                                                   7\/8\n  Verifying  : clamav-0.98.7-1.el7.x86_64                                                                                                                                                      8\/8\n\nInstalled:\n  clamav.x86_64 0:0.98.7-1.el7                        clamav-devel.x86_64 0:0.98.7-1.el7          clamav-scanner-systemd.noarch 0:0.98.7-1.el7         clamav-server.x86_64 0:0.98.7-1.el7\n  clamav-server-systemd.noarch 0:0.98.7-1.el7         clamav-update.x86_64 0:0.98.7-1.el7\n\nDependency Installed:\n  clamav-scanner.noarch 0:0.98.7-1.el7                                                                nmap-ncat.x86_64 2:6.40-7.el7\n\nComplete!\n\n<\/pre>\n<p>Copy a the clamd.conf template, in case you don\u2019t have a configuration file yet:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# cp \/usr\/share\/clamav\/template\/clamd.conf \/etc\/clamd.d\/clamd.conf\n<\/pre>\n<p>Change the file and Comment out &#8220;Example&#8221;<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# nano \/etc\/clamd.d\/clamd.conf\n<\/pre>\n<p>Change this&#8230;<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# Comment or remove the line below.\nExample\n<\/pre>\n<p>To this&#8230;<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# Comment or remove the line below.\n#Example\n<\/pre>\n<p>Configure SELinux for ClamAV.<\/p>\n<p>Check if selinux in on:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# getenforce\nEnforcing\n&#x5B;root@database ~]# sestatus\nSELinux status:                 enabled\nSELinuxfs mount:                \/sys\/fs\/selinux\nSELinux root directory:         \/etc\/selinux\nLoaded policy name:             targeted\nCurrent mode:                   enforcing\nMode from config file:          enforcing\nPolicy MLS status:              enabled\nPolicy deny_unknown status:     allowed\nMax kernel policy version:      28\n\n<\/pre>\n<p>Write this command to get it working with SELinux if this is active:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# setsebool -P antivirus_can_scan_system 1\n\n<\/pre>\n<p>Enabling and Disabling SELinux<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\nnano \/etc\/sysconfig\/selinux\n\n<\/pre>\n<p>To enable&#8230;set this to enforcing<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# SELINUX=enforcing\n\n<\/pre>\n<p>To disable, set to permissive<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# SELINUX=permissive\n<\/pre>\n<p>Reboot after changes<\/p>\n<p>Or, to make temp changes:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# setenforce permissive\n<\/pre>\n<p>Enable Freshclam<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# cp \/etc\/freshclam.conf \/etc\/freshclam.conf.bak\n<\/pre>\n<p>Edit the config file to comment out example<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# nano \/etc\/freshclam.conf\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# Comment or remove the line below.\n#Example\n\n<\/pre>\n<p>Creat a file<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# nano \/usr\/lib\/systemd\/system\/clam-freshclam.service\n<\/pre>\n<p>Add<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# Run the freshclam as daemon\n&#x5B;Unit]\nDescription = freshclam scanner\nAfter = network.target\n \n&#x5B;Service]\nType = forking\nExecStart = \/usr\/bin\/freshclam -d -c 4\nRestart = on-failure\nPrivateTmp = true\n \n&#x5B;Install]\nWantedBy=multi-user.target\n<\/pre>\n<p>Let&#8217;s enable and start the service<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# systemctl enable clam-freshclam.service\n# systemctl start clam-freshclam.service\n<\/pre>\n<p>rename the \/usr\/lib\/systemd\/system\/clamd@.service file<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# mv \/usr\/lib\/systemd\/system\/clamd@.service \/usr\/lib\/systemd\/system\/clamd.service\n<\/pre>\n<p>change the clamd@scan service as well. Change this line in \/usr\/lib\/systemd\/system\/clamd@scan.service and remove the @ sign<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# nano \/usr\/lib\/systemd\/system\/clamd@scan.service\n<\/pre>\n<p>From&#8230;<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# .include \/lib\/systemd\/system\/clamd@.service\n<\/pre>\n<p>to&#8230;<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# .include \/lib\/systemd\/system\/clamd.service\n<\/pre>\n<p>change the clamd service file \/usr\/lib\/systemd\/system\/clamd.service:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n&#x5B;Unit]\nDescription = clamd scanner daemon\nAfter = syslog.target nss-lookup.target network.target\n \n&#x5B;Service]\nType = simple\nExecStart = \/usr\/sbin\/clamd -c \/etc\/clamd.d\/clamd.conf --nofork=yes\nRestart = on-failure\nPrivateTmp = true\n \n&#x5B;Install]\nWantedBy=multi-user.target\n<\/pre>\n<p>Start all services<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n#cd \/usr\/lib\/systemd\/system\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# systemctl enable clamd.service\n# systemctl enable clamd@scan.service\n# systemctl start clamd.service\n# systemctl start clamd@scan.service.\n<\/pre>\n<p>Run a scan<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# clamscan -i -r --log=\/var\/log\/clamscan-date.txt \/var\/www\/vhosts\/*\n\n----------- SCAN SUMMARY -----------\nKnown viruses: 4159219\nEngine version: 0.98.7\nScanned directories: 3\nScanned files: 116\nInfected files: 0\nData scanned: 13.64 MB\nData read: 39.54 MB (ratio 0.34:1)\nTime: 10.738 sec (0 m 10 s)\n\n<\/pre>\n<p>Set up a cron to run a scan (example is for a plesk server for the virtual hosts<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# nano \/etc\/cron.daily\/clamscan\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n#!\/bin\/bash\n# setup the scan location and scan log\nCLAM_SCAN_DIR=&quot;\/var\/www\/vhosts&quot;\nCLAM_LOG_FILE=&quot;\/var\/log\/clamav\/dailyscan.log&quot;\n# update the virus database\n\/usr\/bin\/freshclam\n# run the scan\n\/usr\/bin\/clamscan -i -r $CLAM_SCAN_DIR &gt;&gt; $CLAM_LOG_FILE\nMAILTO=user@domain.com\n<\/pre>\n<p>Set the cron file as an executible<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# chmod 555 \/etc\/cron.daily\/clamscan\n\n<\/pre>\n<p>Test your installation and cron job<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# \/etc\/cron.daily\/clamscan\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Install ClamAV and set up scheduled scans. Install Epel: # yum install epel-release Install ClmAV # yum install clamav-server clamav-data clamav-update clamav-filesystem clamav clamav-scanner-systemd clamav-devel clamav-lib clamav-server-systemd Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.lax.hugeserver.com * epel: dl.fedoraproject.org * extras: dallas.tx.mirror.xygenhosting.com * updates: linux.mirrors.es.net Package clamav-data-0.98.7-1.el7.noarch already installed and latest version &#8230; <a title=\"Install ClamAV on CentOS 7\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2015\/12\/16\/install-clamav-on-centos-7\/\" aria-label=\"Read more about Install ClamAV on CentOS 7\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,12,15],"tags":[],"class_list":["post-2850","post","type-post","status-publish","format-standard","hentry","category-administration","category-centos-7","category-clamav"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/2850","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=2850"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/2850\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=2850"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=2850"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=2850"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}