{"id":984,"date":"2019-11-26T12:47:19","date_gmt":"2019-11-26T00:47:19","guid":{"rendered":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/?p=984"},"modified":"2019-11-26T12:47:19","modified_gmt":"2019-11-26T00:47:19","slug":"converting-a-fedora30-webserver-to-centos7","status":"publish","type":"post","link":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/?p=984","title":{"rendered":"Converting a Fedora30 webserver to CentOS7"},"content":{"rendered":"<p>There are two supported versions of CentOS in the wild now.<br \/>\nNote that I exclude CentOS6 as that is pretty much end of support now. So we have only versions 7 and 8 to play with.<br \/>\nVersion 7 is EOL in 2024, 8 is EOL in 2029.<\/p>\n<p>My reason for requiring CentOS was that Docker does not run out-of-the-box on Fedora31 so I was dubious about any future support for it there, and it was safer to move to a supported OS rather than just pray that the Docker team would bother with updating their packages for Fedora.<\/p>\n<p>RHEL8 (and therefore CentOS8 also) has dropped support for docker within their repositories so I had to rule out CentOS8. I may revisit that if the Docker packaging teams ever create their own upstream repository to support RHEL8.<\/p>\n<p>So this post is on installing CentOS7 and the required packages I needed to migrate my webserver from F30 to CentOS7.<\/p>\n<p>The conversion was relatively painless.<\/p>\n<ul>\n<li>all my custom C compiled binaries simply copied across from Fedora30 and ran on CentOS7, a great benefit as I can for now keep my dev machine on Fedora<\/li>\n<li>mysqldump of databases on Fedora loaded into CentOS7 perfectly<\/li>\n<li>all the PHP based applications could simply have their directories (and http conf.d entries as appropriate) copied to the new server and worked with the loaded database entries&#8230; after PHP was upgraded of course<\/li>\n<\/ul>\n<p>The major steps needed for the conversion are documented below.<\/p>\n<h2>Issues with creating the virtual machine under Fedora31<\/h2>\n<p>My host machines are currently both on Fedora31, the ISO I was using was CentOS-7-x86_64-Everything-1503-01.iso.<\/p>\n<p>There was a rather large issue in building the VM, but I got there in the end.<\/p>\n<ul>\n<li>virt-manager does not allow configuration of IDE disks<\/li>\n<li>the CentOS7 install <em>requires<\/em> IDE disks, it could not locate disks created by virt-manager as virtio (or sata)<\/li>\n<li>to have IDE disks available requires the emulator \/usr\/bin\/qemu-kvm but virt-manager on f31 only uses \/usr\/bin\/qemu-system-x86_64<\/li>\n<\/ul>\n<p>The resolution to this was to manually create a VM XML file (based on a CentOS7 VM I created a looong time ago when virt-manager did allow IDE, just updating things like name, uuid, disk name, mac address etc to match values used in the failed Centos7 attempt), precreate the qcow2 disk and simply &#8216;virsh define xx.xml&#8217; to define the VM.<\/p>\n<p>At that point I could use virt-manager to select the cdrom as the boot device and install CentOS7 without further problems. I was also able to check that CentOS7 had all the packages available that I would need to migrate my webserve from Fedora to CentOS. Remembering of course to use &#8216;yum -y install epel-release&#8217;.<\/p>\n<h2>Upgrading PHP to 7.3<\/h2>\n<p>CentOS7 shipped with php5.4 which is no longer supported, and most web applications will not even run on such and old version.<\/p>\n<p>php7.4 is available for CentOS7, but I chose to use 7.3 to match what was already running on my existing webserver.<\/p>\n<p>Rather than rewrite existing documentation this ecternal post on <a href=\"https:\/\/linuxize.com\/post\/install-php-7-on-centos-7\/\">installing php 7.3 on CentOS7<\/a> covers all the steps needed. The procedure worked without error&#8230; although I did one additional step before following the procedure whist was to remove all the php5.4 packages installed by default with CentOS7.<\/p>\n<h2>Installing Jetty<\/h2>\n<p>A &#8220;yum search jetty&#8221; did not find an all encompassing package that would install Jetty, and I was not keen on just installing every package beginning with jetty.<\/p>\n<p>Instead I followed the documentation on <a href=\"https:\/\/www.linuxhelp.com\/how-to-install-jetty-on-centos-7\">installing jetty on CentOS7<\/a> from the linuxhelp site. The procedure documented there worked without any problems.<\/p>\n<p>The only additional step I had to do was move my apps from \/var\/lib\/jetty\/webapps (where F30 required them) to \/opt\/jetty\/webapps where the manual install expects Jetty apps.<\/p>\n<h2>The EFF Certbot<\/h2>\n<p>I chose to install the version of Certbot recomended for CentOS8, the best choice as I had upgraded php.<\/p>\n<p>Again the documentation on <a href=\"https:\/\/certbot.eff.org\/lets-encrypt\/centosrhel8-apache\">installing certbot<\/a> is easy to follow.<\/p>\n<p>After downloading the certbot-auto file I chose perform only the &#8220;certbot-auto &#8211;install-only -v&#8221; step, which worked without issues.<\/p>\n<p>I have not yet tried the &#8220;certbot-auto renew&#8221; comamnd to obtain new certificates as the ones I use are nowhere near their expiry date.<\/p>\n<h2>Puppet Agent<\/h2>\n<p>I use puppet for configuring my servers, installing the puppet agent was simply<\/p>\n<pre>\r\nrpm -Uvh https:\/\/yum.puppetlabs.com\/puppetlabs-release-pc1-el-7.noarch.rpm\r\nyum install puppet-agent\r\nsystemctl enable puppet\r\n<\/pre>\n<h2>MariaDB Databases<\/h2>\n<p>The mariadb databases were simple to migrate as my webserver takes hourly database dumps.<\/p>\n<p>On the new CentOS7 server it was simple a case of installing mariadb-server and starting the mariadb service, and running the secure setup script to get a nice clean setup.<\/p>\n<p>Then sourcing (\\.) the latest dump file from the Fedora30 server. This completed with no errors and all users, databases and database grants etc. were in place and working; tested by logging onto all the apps that use the database to confirm stored app userids worked and apps behaved as expected.<\/p>\n<h2>PHP based applications<\/h2>\n<p>All the PHP based applications (including wordpress) I use were able to be simply migrated across to the new server as part of the httpd directory structure copy, with the following additional steps<\/p>\n<ul>\n<li>webcollab: simply required &#8220;yum install php-mbstring&#8221;<\/li>\n<li>owncloud: &#8220;yum install php-pecl-zip php-intl php-xml&#8221;, but see notes below<\/li>\n<\/ul>\n<p>Owncloud server components do not exist in OS distribution repositories. You obtain the owncloud-files package from <a href=\"https:\/\/download.owncloud.org\/download\/repositories\/production\/owncloud\/\">https:\/\/download.owncloud.org\/download\/repositories\/production\/owncloud\/<\/a>.<\/p>\n<p>As I was installing onto CentOS7 I downloaded the rpm file for CentOS8 and manually installed it (rpm -i xxx.rpm), it matched the version used on Fedora30 so should work with the existing databases once the DNS entries for the server are changed so your clients point to it.<\/p>\n<p>I chose to create a completely new database and re-install as I only one sync user (myself) so I could just re-add my credentials..<\/p>\n<h2>Snort intrusion detection system (IDS)<\/h2>\n<p>This was simply a case of &#8220;yum -y install libtool libpcap-devel libdnet-devel bison flex&#8221; then recompiling the DAQ and snort binaries.<\/p>\n<p>As I installed using the default configuration files (mainly to allow me to document the changes) rather than just copy across my existing configurations there was also a bit of manual customisation needed as shown below.<\/p>\n<p>Assuming you have downloaded the snort and daq static source from the snort website (and installed the packages listed two paragraphs up) the steps to get snort installed are below; note that I placed the sources in \/home\/mark\/installs\/snort so change that location to the one you used.<\/p>\n<pre>\r\ncd \/home\/mark\/installs\/snort\/daq-2.0.6\r\n.\/configure\r\nmake\r\nmake install\r\nmake clean\r\n\r\ncd \/home\/mark\/installs\/snort\/snort-2.9.12\r\n.\/configure --enable-sourcefire --disable-open-appid\r\nmake\r\nmake install\r\nmake clean\r\n\r\nmkdir \/etc\/snort\r\ncd \/etc\/snort\r\ncp \/home\/mark\/installs\/snort\/snort-2.9.12\/etc\/* .\r\n<\/pre>\n<p>And you will need to add a user and group for snort, the group snort is added automatically when the user is added with system defaults.<br \/>\nSimply &#8220;useradd snort&#8221;. Do that at this point as we will be changing filesystem permissions to this user in later steps.<\/p>\n<p>Using the community rules (the free rule packages for snort) quite a bit of editing of the snort.conf file. As you should edit it to define a trusted home network anyway lets edit the snort.conf file.<\/p>\n<p>Rather than go into details, as this post is not about installing snort, below is a &#8220;diff&#8221; between the supplied snort.conf and my customised one ( < is my changes, > is the origional line ).<\/p>\n<pre>\r\n< #ipvar HOME_NET any\r\n< ipvar HOME_NET 192.168.1.0\/24\r\n> ipvar HOME_NET any\r\n< #ipvar EXTERNAL_NET any\r\n< ipvar EXTERNAL_NET !$HOME_NET\r\n> ipvar EXTERNAL_NET any\r\n\r\n< var RULE_PATH \/etc\/snort\/community-rules\r\n< var SO_RULE_PATH \/etc\/snort\/so_rules\r\n< var PREPROC_RULE_PATH \/etc\/snort\/preproc_rules\r\n> var RULE_PATH ..\/rules\r\n> var SO_RULE_PATH ..\/so_rules\r\n> var PREPROC_RULE_PATH ..\/preproc_rules\r\n\r\n< var WHITE_LIST_PATH \/etc\/snort\/community-rules\r\n< var BLACK_LIST_PATH \/etc\/snort\/community-rules\r\n> var WHITE_LIST_PATH ..\/rules\r\n> var BLACK_LIST_PATH ..\/rules\r\n\r\n< include $RULE_PATH\/community.rules\r\n> include $RULE_PATH\/local.rules\r\n\r\nA N D -------- comment out all folowing includes after the community.rules\r\n               entry as they are not provided with the community rules.\r\n<\/pre>\n<p>As mentioned above I use the community rules. To install those simply follow the below steps.<\/p>\n<pre>\r\n<em>\r\nmkdir \/tmp\/snort\r\ncd \/tmp\/snort\r\nwget https:\/\/www.snort.org\/rules\/community\r\ncd \/etc\/snort\r\ntar -zxvf \/tmp\/snort\/community\r\n\/bin\/rm \/tmp\/snort\/community\r\nrmdir \/tmp\/snort\r\n<\/em>\r\nmkdir \/usr\/local\/lib\/snort_dynamicrules\r\ntouch \/etc\/snort\/community-rules\/black_list.rules\r\ntouch \/etc\/snort\/community-rules\/white_list.rules\r\nmkdir \/var\/log\/snort\r\nchown snort:snort \/var\/log\/snort\r\n<\/pre>\n<p>The commands in emphasis above should be placed into a weekly cron job along with a restart of snort to ensure you keep the rules up to date.<\/p>\n<p><b>You will need to create a startup\/shutdown script<\/b>. The start command is (replace ens3 with your interface name)<\/p>\n<pre>\r\n\/usr\/local\/bin\/snort -D -A fast -b -d -i ens3 -u snort -g snort -c \/etc\/snort\/snort.conf -l \/var\/log\/snort -b\r\n<\/pre>\n<p>Note: for testing run in foreground with &#8220;\/usr\/local\/bin\/snort -A fast -b -d -i eth0 -u snort -g snort -c \/etc\/snort\/snort.conf -l \/var\/log\/snort -b&#8221; so all errors are written to your terminal.<\/p>\n<h2>Summary<\/h2>\n<p>Conversion from Fedora30 to CentOS7 is a fairly painless exercise. Most of the work needed I did in two days to get a fully working server. I spent an additional three days was spent on customising\/testing puppet rules for this CentOS7 system (as some packages are different to Fedora), testing bacula backups\/restores, penetration testing etc; basically a lot of stuff most users do not need to do.<\/p>\n<p>Was the conversion sucessfull ?. You are viewing this post on the CentOS7 server, so yes :-).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are two supported versions of CentOS in the wild now. Note that I exclude CentOS6 as that is pretty much end of support now. So we have only versions 7 and 8 to play with. Version 7 is EOL &hellip; <a href=\"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/?p=984\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-984","post","type-post","status-publish","format-standard","hentry","category-my-nux-thoughts-and-notes"],"_links":{"self":[{"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/984","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=984"}],"version-history":[{"count":2,"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/984\/revisions"}],"predecessor-version":[{"id":986,"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/984\/revisions\/986"}],"wp:attachment":[{"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=984"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=984"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=984"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}