{"id":3761,"date":"2019-09-15T12:01:48","date_gmt":"2019-09-15T00:01:48","guid":{"rendered":"http:\/\/www.zoyinc.com\/?p=3761"},"modified":"2020-04-17T14:52:00","modified_gmt":"2020-04-17T02:52:00","slug":"centos-7-vm-for-wordpress-and-mythtv-post-install-setup","status":"publish","type":"post","link":"http:\/\/www.zoyinc.com\/?p=3761","title":{"rendered":"CentOS 7 VM for WordPress and MythTV &#8211; Post install setup"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3878\" src=\"http:\/\/www.zoyinc.com\/wp-content\/uploads\/2019\/09\/CentoOS7VM_PostInstallSetup02.jpg\" alt=\"\" width=\"1232\" height=\"335\" srcset=\"http:\/\/www.zoyinc.com\/wp-content\/uploads\/2019\/09\/CentoOS7VM_PostInstallSetup02.jpg 1232w, http:\/\/www.zoyinc.com\/wp-content\/uploads\/2019\/09\/CentoOS7VM_PostInstallSetup02-150x41.jpg 150w, http:\/\/www.zoyinc.com\/wp-content\/uploads\/2019\/09\/CentoOS7VM_PostInstallSetup02-300x82.jpg 300w, http:\/\/www.zoyinc.com\/wp-content\/uploads\/2019\/09\/CentoOS7VM_PostInstallSetup02-768x209.jpg 768w, http:\/\/www.zoyinc.com\/wp-content\/uploads\/2019\/09\/CentoOS7VM_PostInstallSetup02-500x136.jpg 500w\" sizes=\"auto, (max-width: 1232px) 100vw, 1232px\" \/><\/p>\n<p>In the post\u00a0<a  href=\"http:\/\/www.zoyinc.com\/?p=3726\">CentOS 7 base VM for WordPress and MythTV<\/a> I described how to create a base CentOS 7 VM. This post describes follows on from that post and describes the post installation tasks to make the VM a good solid base for me to run WordPress or MythTV.<\/p>\n<p>When setting up a Linux server there are a lot of choices you make and some of the more important ones are around security. There is an enormous amount you can do to lock down a server but it comes at a cost to time, effort and inconvenience.<\/p>\n<p>This setup is based on my requirements. My MythTV box is sitting on our LAN behind a reasonable firewall, it&#8217;s not used to surf the internet, it&#8217;s a media player.<\/p>\n<p>The WordPress server is in a DMZ completely separated from the LAN &#8211; from the LAN you can get to it but it can&#8217;t get to the LAN. It is sitting behind the same SonicWall firewall. I am planning on setting up WordPress to do daily backups of the DB and filesystem. So if it gets hacked then I rollback to a &#8220;known good&#8221; copy of the VM and then the backups are restored to it. I don&#8217;t believe I need firewalls on the host and because only HTTP and HTTPS are exposed I think security is adequate.Initial stuff<\/p>\n<h1>Generic<\/h1>\n<h2>Disable SE Linux<\/h2>\n<p>SE Linux has it&#8217;s place but it is complicated to administer and is not required for my boxes. When enabled it can cause all sorts of weird things not to work, things that I have spent hours trying to nut out only find it was SE Linux.<\/p>\n<p>Best to disable it right at the beginning!<\/p>\n<p>Backup and then edit the file \/etc\/selinux\/config<\/p>\n<p>Set the following:<\/p>\n<p style=\"padding-left: 30px;\">SELINUX=disabled<\/p>\n<p>Save the file<\/p>\n<h2>Disable the firewall<\/h2>\n<p>Run the following:<\/p>\n<p style=\"padding-left: 30px;\">sudo systemctl stop firewalld<br \/>\nsudo systemctl disable firewalld<br \/>\nsudo systemctl mask &#8211;now firewalld<\/p>\n<h2>Install the GUI &#8211; User Manager<\/h2>\n<p>This appears under &#8220;Sundry&#8221; in desktop menu. Run the following:<\/p>\n<p>yum install system-config-users<\/p>\n<h2>Miscellaneous<\/h2>\n<p>Run the following to install any missing items:<\/p>\n<p style=\"padding-left: 30px;\">yum install telnet<\/p>\n<p>Enable the epel repo<\/p>\n<p style=\"padding-left: 30px;\">sudo yum install epel-release<br \/>\nrpm -Uvh http:\/\/rpms.famillecollet.com\/enterprise\/remi-release-7.rpm<\/p>\n<p>Enable software collections, scl:<\/p>\n<p style=\"padding-left: 30px;\">yum update<br \/>\nyum install centos-release-scl<br \/>\nyum install scl-utils-build<\/p>\n<p>You should edit the file \u201c\/etc\/yum.conf\u201d and look for the line:<\/p>\n<p style=\"padding-left: 30px;\">installonly_limit=5<\/p>\n<p>Change this to a 2. This is to stop previous kernels filling up the &#8220;\/boot&#8221; partition. See my post: <a  href=\"http:\/\/www.zoyinc.com\/?p=3820\">Low Disk Space on \u201cboot\u201d<\/a><\/p>\n<h2>Restart the host<\/h2>\n<p>Would be good to restart the VM now, just to make sure everything still works and ensure that SELinux is disabled.<\/p>\n<h2>Create users and Groups<\/h2>\n<p>We some custom users and groups. Create the following:<\/p>\n<p style=\"padding-left: 30px;\">groupadd sambaguest<br \/>\nuseradd sambaguest -d \/home\/sambaguest -g sambaguest -s \/bin\/bash<br \/>\ngroupadd backup<br \/>\nuseradd backup -d \/home\/backup -g backup -s \/bin\/bash<\/p>\n<p>&nbsp;<\/p>\n<h1>Install MariaDB<\/h1>\n<p>MariaDB replaces MySQL but the version that comes with CentOS is 5.5.60 and we need version 10 for WordPress. You will note we have not yet selected to install either MariaDB or MySQL.<\/p>\n<p>yum install rh-mariadb102<\/p>\n<p>Enable the software collection and start the service<\/p>\n<p style=\"padding-left: 30px;\">scl enable rh-mariadb102 bash<br \/>\nservice rh-mariadb102-mariadb start<\/p>\n<p>Setup MariaDB<\/p>\n<p style=\"padding-left: 30px;\">mysql_secure_installation\u00a0\u00a0\u00a0 (If you exited bash you will have to run &#8220;scl enable rh-mariadb102 bash&#8221; again)<\/p>\n<p>You will be prompted with some questions. Below are the questions and my answers:<\/p>\n<p style=\"padding-left: 30px;\">Enter current password for root = This is the root database user, (First time this will be blank)<br \/>\nSet root password? [Y\/n] = Y<br \/>\nNew password: ******<br \/>\nRemove anonymous users? [Y\/n] = Y<br \/>\nDisallow root login remotely? [Y\/n] = n<br \/>\nRemove test database and access to it? [Y\/n] = Y<br \/>\nReload privilege tables now? [Y\/n] = Y<\/p>\n<p>I want to be able to connect remotely as the root user so run the following. Note when you first login remember it is the root password for the DB user remote. Where I have &#8220;&lt;root password&gt;, again this is the DB root user:<\/p>\n<p style=\"padding-left: 30px;\">mysql -u root -p<br \/>\nGRANT ALL PRIVILEGES ON *.* TO &#8216;root&#8217;@&#8217;%&#8217; IDENTIFIED BY &#8216;&lt;root password&gt;&#8217; WITH GRANT OPTION;<br \/>\nGRANT ALL ON *.* to &#8216;root&#8217;@&#8217;%&#8217;;<br \/>\nuse mysql;<br \/>\nUPDATE user SET authentication_string=PASSWORD(&#8216;&lt;root password&gt;&#8217;) where User=&#8217;root&#8217;;<br \/>\nUPDATE user SET plugin=&#8221;mysql_native_password&#8221;;<br \/>\nFLUSH PRIVILEGES;<br \/>\nexit<\/p>\n<p>The &#8216;WITH GRANT OPTION&#8217; is important otherwise even though you did grant all privileges this doesn&#8217;t appear to include GRANT.<\/p>\n<p>You should enable timezones which is required for MythTV if not others. Ensure you are still running &#8220;scl enable rh-mariadb102 bash&#8221;. Run the following<\/p>\n<p style=\"padding-left: 30px;\">mysql_tzinfo_to_sql \/usr\/share\/zoneinfo | mysql -u root mysql -p<\/p>\n<p>This will prompt you for the password for the root user in MariaDB &#8211; not the Unix account, the MariaDB root account. You may also get some warnings :<\/p>\n<pre class=\"crayon:false;\">[root@mythsvr2 ~]# mysql_tzinfo_to_sql \/usr\/share\/zoneinfo | mysql -u root mysql -p\r\nEnter password: \r\nWarning: Unable to load '\/usr\/share\/zoneinfo\/leapseconds' as time zone. Skipping it.\r\nWarning: Unable to load '\/usr\/share\/zoneinfo\/tzdata.zi' as time zone. Skipping it.<\/pre>\n<p>Now enable MariaDB so it will autostart:<\/p>\n<p style=\"padding-left: 30px;\">systemctl enable rh-mariadb102-mariadb.service<\/p>\n<p>At this stage I would try to connect remotely as root, using say HeidiSQL. I would then restart the VM and double check that Maria has restarted &#8211; it should do.<\/p>\n<h1>PostgreSQL 10<\/h1>\n<p>This is available in Software collections so begin by installing:<\/p>\n<p>yum install rh-postgresql10 rh-postgresql10-postgresql-devel<\/p>\n<p>Now scl enable PostgreSQL, initialize the DB then enable and start the service:<\/p>\n<p style=\"padding-left: 30px;\">scl enable rh-postgresql10 bash<br \/>\npostgresql-setup &#8211;initdb<br \/>\nsystemctl enable rh-postgresql10-postgresql.service<br \/>\nservice rh-postgresql10-postgresql start<\/p>\n<p>Note &#8220;&#8211;initdb&#8221; doesn&#8217;t ask any questions, just initializes.<\/p>\n<p>To enable remote access, from the LAN etc, we need to edit two files &#8220;pg_hba.conf&#8221; and &#8220;postgresql.conf&#8221;. Because this is running under software collections the folder is:<\/p>\n<p>\/var\/opt\/rh\/rh-postgresql10\/lib\/pgsql\/data<\/p>\n<p>So run the following commands<\/p>\n<p style=\"padding-left: 30px;\">systemctl stop rh-postgresql10-postgresql.service<br \/>\ncd \/var\/opt\/rh\/rh-postgresql10\/lib\/pgsql\/data<br \/>\ncp pg_hba.conf pg_hba.conf.ootb<br \/>\ncp postgresql.conf postgresql.conf.ootb<\/p>\n<p>Now edit postgresql.conf using your favorite editor and add the following lines at the bottom: access:<\/p>\n<p style=\"padding-left: 30px;\"># centos7-base customizations<br \/>\nlisten_addresses = &#8216;*&#8217;<\/p>\n<p>Now edit &#8220;pg_hba.conf&#8221; in the same folder and add the following lines:<\/p>\n<p style=\"padding-left: 30px;\">host all all 0.0.0.0\/0 md5<br \/>\nhost all all ::\/0 md5<\/p>\n<p>In the same file, &#8220;pg_hba.conf&#8221;, look for the following lines near the bottom:<\/p>\n<p style=\"padding-left: 30px;\"># &#8220;local&#8221; is for Unix domain socket connections only<br \/>\nlocal all all <span style=\"background-color: #ffff00;\">peer<\/span><br \/>\n# IPv4 local connections:<br \/>\nhost all all 127.0.0.1\/32 <span style=\"background-color: #ffff99;\">ident<\/span><\/p>\n<p>and change the highlighted text to as below:<\/p>\n<p style=\"padding-left: 30px;\"># &#8220;local&#8221; is for Unix domain socket connections only<br \/>\nlocal all all <span style=\"background-color: #ffff99;\">trust<\/span><br \/>\n# IPv4 local connections:<br \/>\nhost all all 127.0.0.1\/32 <span style=\"background-color: #ffff99;\">trust<\/span><\/p>\n<p>Now restart PostgreSQL and try to connect from your LAN computer.<\/p>\n<p>We now need to create a DB &#8220;root&#8221; user. This is different from the Linux account &#8220;root&#8221;. Because we need to do this via scl and scl clears environment variables, we can&#8217;t simply run &#8220;psql&#8221; we need to run the following:<\/p>\n<p style=\"padding-left: 30px;\">su &#8211; postgres -c &#8216;scl enable rh-postgresql10 &#8212; psql&#8217;<\/p>\n<p>This should put you into psql with a prompt &#8220;postgres=#&#8221;. To create the &#8220;root&#8221; DB user run:<\/p>\n<p style=\"padding-left: 30px;\">CREATE ROLE root SUPERUSER LOGIN PASSWORD &#8216;&lt;my root DB password&gt;&#8217;;<\/p>\n<p>To exit psql type &#8220;\\q&lt;enter&gt;&#8221;.<\/p>\n<p>At this point it would be a good idea to restart the VM and check that PostgreSQL starts on boot and that the login also works.<\/p>\n<h1>Apache, PHP and Python<\/h1>\n<p>To install Apache 2.4, PHP 7.2 and Python 3.6 and have them all working together I installed them all using Software Collections. You can read about what I did in the post <a  href=\"http:\/\/www.zoyinc.com\/?p=3780\">CentOS 7 + PHP 7.2 + Python 3.6 + Apache 2.4<\/a><\/p>\n<h2>Create Apache users<\/h2>\n<p>I authenticate my users using basic authentication created by Apache&#8217;s htpasswd. For this box we will create some custom users.<\/p>\n<p>Run<\/p>\n<p style=\"padding-left: 30px;\">scl enable httpd24 bash<br \/>\nhtpasswd -c \/srv\/conf\/apache.users tony<br \/>\nhtpasswd \/srv\/conf\/apache.users svnanonymous<br \/>\nexit<\/p>\n<p>So this will create the file and create a user &#8220;tony&#8221; and one called &#8220;svnanonymous&#8221;. Also create an Apache group file:<\/p>\n<pre class=\"crayon:false;\">admin: tony\r\nfamily: tony jackie josh\r\nsvn: tony jackie josh svn<\/pre>\n<h2>Self-signed SSL certificate<\/h2>\n<p>The goal is not to use self-signed certificates are these are not trusted by default. However should you want to go down this path, this is what to do.<\/p>\n<p>You should follow the instructions in the post\u00a0<a  href=\"http:\/\/www.zoyinc.com\/?p=822\">Adding an SSL certificate to Apache<\/a> , <strong><span style=\"text-decoration: underline;\">however,<\/span><\/strong> as you know we are using the software collections httpd24, which is the Apache httpd, so when the instructions say to move to:<\/p>\n<p style=\"padding-left: 30px;\">cd \/etc\/httpd\/conf.d<\/p>\n<p>You should instead move to:<\/p>\n<p style=\"padding-left: 30px;\">\/opt\/rh\/httpd24\/root\/etc\/httpd\/conf.d<\/p>\n<p>Otherwise the instructions are fine for creating the ssl certificate.<\/p>\n<p>Next you need to edit the ssl config file for Apache. So edit:<\/p>\n<p style=\"padding-left: 30px;\">\/opt\/rh\/httpd24\/root\/etc\/httpd\/conf\/ssl.conf<\/p>\n<p>Add:<\/p>\n<p style=\"padding-left: 30px;\">NSSEnforceValidCerts off<\/p>\n<p>Change:<\/p>\n<p style=\"padding-left: 30px;\">SSLCertificateFile \/etc\/pki\/tls\/certs\/localhost.crt<\/p>\n<p>to<\/p>\n<p style=\"padding-left: 30px;\">SSLCertificateFile \/opt\/rh\/httpd24\/root\/etc\/httpd\/conf.d\/zoyinc.com.crt<\/p>\n<p>Then change:<\/p>\n<p style=\"padding-left: 30px;\">SSLCertificateKeyFile \/opt\/rh\/httpd24\/root\/etc\/httpd\/conf.d\/zoyinc.com.key<\/p>\n<p>to:<\/p>\n<p style=\"padding-left: 30px;\">SSLCertificateFile \/opt\/rh\/httpd24\/root\/etc\/httpd\/conf.d\/zoyinc.com.key<\/p>\n<p>You can test your changes by running:<\/p>\n<p style=\"padding-left: 30px;\">scl enable http24-httpd bash<br \/>\nhttpd -t<br \/>\nexit<\/p>\n<h1>Tomcat<\/h1>\n<p>Follow the instructions in <a  href=\"http:\/\/www.zoyinc.com\/?p=3815\">Installing Tomcat 9 behind Apache on CentOS 7<\/a><\/p>\n<h1>Subversion<\/h1>\n<p>Running SVN and using it in Apache and running Apache via scl means SVN also has to be run in scl. The bit that is not obvious is the software collection you need is actually <strong>sclo-subversion19<\/strong>.<\/p>\n<p>Note that for software collections:<\/p>\n<ul>\n<li>&#8220;rh-&#8221; signifies &#8220;<em>Red Hat&#8217;s collections available in Red Hat Software Collections product<\/em>&#8220;, see <a  href=\"https:\/\/wiki.centos.org\/SpecialInterestGroup\/SCLo\">SpecialInterestGroup\/SCLo &#8211; CentOS Wiki<\/a><\/li>\n<li>&#8220;sclo-&#8221; signifies &#8220;<em>Software Collections not being rebases of RHSCL collections<\/em>&#8220;, &#8220;<em>collections created by the community<\/em>&#8220;. Also see <a  href=\"https:\/\/wiki.centos.org\/SpecialInterestGroup\/SCLo\">SpecialInterestGroup\/SCLo &#8211; CentOS Wiki<\/a><\/li>\n<\/ul>\n<p>So you should install sclo-subversion and a number of supporting packages<\/p>\n<p style=\"padding-left: 30px;\">yum install sclo-subversion19 sclo-subversion19-mod_dav_svn sclo-subversion19-subversion-devel sclo-subversion19-subversion-python sclo-subversion19-subversion-tools<\/p>\n<p>For our purposes the important module is &#8220;sclo-subversion19-mod_dav_svn&#8221; this delivers the following files:<\/p>\n<pre class=\"crayon:false;\">\/opt\/rh\/httpd24\/root\/etc\/httpd\/conf.modules.d\/10-subversion.conf\r\n\/opt\/rh\/httpd24\/root\/usr\/lib64\/httpd\/modules\/mod_authz_svn.so\r\n\/opt\/rh\/httpd24\/root\/usr\/lib64\/httpd\/modules\/mod_dav_svn.so\r\n\/opt\/rh\/httpd24\/root\/usr\/lib64\/httpd\/modules\/mod_dontdothat.so<\/pre>\n<p>These are clearly the modules we need for Apache.<\/p>\n<p>Create an empty SVN repo if you don&#8217;t have one:<\/p>\n<p style=\"padding-left: 30px;\">scl enable sclo-subversion19 bash<br \/>\ncd \/srv<br \/>\nmkdir svn<br \/>\nsvnadmin create \/srv\/svn\/zoyinc<br \/>\nchown -R apache.apache svn<br \/>\nexit<\/p>\n<p>Lets create an SVN access file. Create file an access file:<\/p>\n<p style=\"padding-left: 30px;\">mkdir -p \/srv\/conf<br \/>\n\/srv\/conf\/svn.access<\/p>\n<p>An example one would be:<\/p>\n<pre class=\"lang:ini decode:true\">[groups]\r\nsvnadmin = tony\r\nsvnanonymous = svnanonymous\r\n\r\n[zoyinc:\/]\r\n@svnadmin = rw\r\n* = \r\n@svnanonymous = \r\n<\/pre>\n<p>Note in the above it is dependant on the earlier section, &#8220;Create Apache users&#8221;.<\/p>\n<p>Then give it rights apache.apache<\/p>\n<p style=\"padding-left: 30px;\">chown apache.apache \/srv\/conf\/svn.access<\/p>\n<p>Update the Apache ssl config:<\/p>\n<p style=\"padding-left: 30px;\">\/opt\/rh\/httpd24\/root\/etc\/httpd\/conf.d\/ssl.conf<\/p>\n<p>find the line:<\/p>\n<p>&lt;\/VirtualHost&gt;<\/p>\n<p>Just before the above add the following:<\/p>\n<pre class=\"lang:default decode:true \">&lt;Location \/svn&gt;\r\n   DAV svn\r\n   SVNListParentPath on\r\n   SVNParentPath \/srv\/svn\r\n   AuthzSVNAccessFile \/srv\/conf\/svn.access\r\n   SSLRequireSSL\r\n   AuthType Basic\r\n   AuthName \"zoyinc.com\"\r\n   AuthUserFile \/srv\/conf\/apache.users\r\n   AuthGroupFile \/srv\/conf\/apache.groups\r\n   Require group svn\r\n&lt;\/location&gt;<\/pre>\n<h1>Samba<\/h1>\n<p>Setup a base smb.conf file. Backup the existing one:<\/p>\n<p style=\"padding-left: 30px;\">cp \/etc\/samba\/smb.conf \/etc\/samba\/smb.conf.ootb<\/p>\n<p>and replace the contents with the sample Samba config file at the bottom of this article.<\/p>\n<p>The sample smb.conf file requires a couple of folders and users that we created earlier:<\/p>\n<p style=\"padding-left: 30px;\">mkdir -p \/mnt\/public<br \/>\nchown -R sambaguest.sambaguest \/mnt\/public<br \/>\nchmod -R 777 \/mnt\/public<br \/>\nmkdir -p \/srv\/backup<br \/>\nchown -R backup.backup \/srv\/backup<br \/>\nchmod -R 770 \/srv\/backup<\/p>\n<p>Then enable and start the services<\/p>\n<p style=\"padding-left: 30px;\">systemctl enable smb.service<br \/>\nsystemctl enable nmb.service<br \/>\nsystemctl restart smb.service<br \/>\nsystemctl restart nmb.service<\/p>\n<p>Remember for any users in Samba you need to create them so for example:<\/p>\n<p style=\"padding-left: 30px;\">smbpasswd -a backup<\/p>\n<p>This will prompt for a password for the user &#8220;backup&#8221;.<\/p>\n<h2>Samba troubleshooting<\/h2>\n<h3>Test tools<\/h3>\n<p><strong>testparm<br \/>\n<\/strong>This is a Samba tool which will validate your smb.conf file and will give you a &#8220;dump of your service definitions&#8221;. Note that the dump is not simply a copy of smb.conf it is what are the effective settings. This is a very handy tool.<\/p>\n<h3>Hostname<\/h3>\n<p>The maximum length of a netbios name is 15 characters and people will always assume the hostname matches the netbios name, so this means the hostname needs to be no more than 15 characters. Originally I called my VM &#8220;centos7-template&#8221;, which is 16 characters, so had to rename &#8220;centos7-base&#8221;.<\/p>\n<h3>Getting guest working<\/h3>\n<p>The &#8220;map to guest = bad user&#8221; parameter maps login attempts with bad usernames to the guest user,<\/p>\n<h3>File limit warning<\/h3>\n<p>If you run testparm and see the following warning:<\/p>\n<p style=\"padding-left: 30px;\">rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)<\/p>\n<p>Edit\u00a0 &#8220;\/etc\/security\/limits.conf&#8221; and add the following to the end of the file:<\/p>\n<p style=\"padding-left: 30px;\">* &#8211; nofile 16385<\/p>\n<p>This will permanently fix the warning. You will need to restart the VM for this to be effective. You can also make a temporary change to the file limit by running:<\/p>\n<p style=\"padding-left: 30px;\">sysctl -w fs.file-max=16385<\/p>\n<h1>AWStats &#8211; logfile analyzer<\/h1>\n<p>AWStats is a great general purpose log file analyzer. I have been using it since 2012 and it is still going strong. Its a really handy way to see if people are actually coming to your site and where they are coming from and so on.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3876\" src=\"http:\/\/www.zoyinc.com\/wp-content\/uploads\/2019\/09\/CentoOS7VM_PostInstallSetup01.jpg\" alt=\"\" width=\"710\" height=\"603\" \/><\/p>\n<p>Install the rpm:<\/p>\n<p style=\"padding-left: 30px;\">yum install awstats<\/p>\n<p>Be warned it has heaps of dependancies, all of which are perl packages.<\/p>\n<p>Run the config as below, it is recommended to cd to the awstats root first:<\/p>\n<p style=\"padding-left: 30px;\">cd \/usr\/share\/awstats<br \/>\ntools\/awstats_configure.pl<\/p>\n<p>These are the options I chose:<\/p>\n<p style=\"padding-left: 30px;\">Do you want to continue setup from this NON standard directory [yN] ? Y<br \/>\nConfig file path (&#8216;none&#8217; to skip web server setup): \/opt\/rh\/httpd24\/root\/etc\/httpd\/conf\/httpd.conf<br \/>\nDo you want me to build a new AWStats config\/profile file (required if first install) [y\/N] ? Y<br \/>\nYour web site, virtual server or profile name: www.zoyinc.com<br \/>\nDirectory path to store config file(s) (Enter for default): &lt;Enter&gt;<\/p>\n<p>The config file is:<\/p>\n<p style=\"padding-left: 30px;\">\/etc\/awstats\/awstats.www.zoyinc.com.conf<\/p>\n<p>You now need to modify the Apache config. This is because the awstats changes are for httpd 2.2 but we are running 2.4 so it goes from:<\/p>\n<p style=\"padding-left: 30px;\">Order allow,deny<br \/>\nAllow from all<\/p>\n<p>to<\/p>\n<p style=\"padding-left: 30px;\">Require all granted<\/p>\n<p>If you don&#8217;t make this change you will get this error:<\/p>\n<p style=\"padding-left: 30px;\"><strong>Forbidden<\/strong><br \/>\nYou don&#8217;t have permission to access \/awstats\/awstats.pl on this server.<\/p>\n<p>So open up the Apache config file:<\/p>\n<p style=\"padding-left: 30px;\">\/opt\/rh\/httpd24\/root\/etc\/httpd\/conf\/httpd.conf<\/p>\n<p>Look for the awstats section:<\/p>\n<p style=\"padding-left: 30px;\">#<br \/>\n# This is to permit URL access to scripts\/files in AWStats directory.<br \/>\n#<br \/>\n&lt;Directory &#8220;\/usr\/share\/awstats\/wwwroot&#8221;&gt;<br \/>\nOptions None<br \/>\nAllowOverride None<br \/>\nOrder allow,deny<br \/>\nAllow from all<br \/>\n&lt;\/Directory&gt;<\/p>\n<p>This needs to be changed to:<\/p>\n<p style=\"padding-left: 30px;\">&lt;Directory &#8220;\/usr\/share\/awstats\/wwwroot&#8221;&gt;<br \/>\nOptions None<br \/>\nAllowOverride None<br \/>\n<span style=\"background-color: #ccffcc;\"># Order allow,deny<\/span><br \/>\n<span style=\"background-color: #ccffcc;\"># Allow from all<\/span><br \/>\n<span style=\"background-color: #ffff99;\">\u00a0\u00a0 Require all granted<\/span><br \/>\n&lt;\/Directory&gt;<\/p>\n<p>Then restart Apache:<\/p>\n<p style=\"padding-left: 30px;\">systemctl restart httpd24-httpd.service<\/p>\n<p>To check the changes are correct now that you have made the Apache changes and restarted Apache, you should visit some pages on your web server. Now have a look at the access log:<\/p>\n<p style=\"padding-left: 30px;\">tail -n 100 \/var\/log\/httpd24\/access_log<\/p>\n<p>The latest entries in the log, after the changes and restart, should look like:<\/p>\n<pre class=\"crayon:false;\">192.168.202.237 - - [11\/Sep\/2019:21:44:55 +1200] \"GET \/awstatsicons\/clock\/hr6.png HTTP\/1.1\" 200 314 \"http:\/\/centos7-base\/awstats\/awstats.pl?config=www.zoyinc.com&amp;framename=mainright\" \"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko\/20100101 Firefox\/69.0\"\r\n192.168.202.237 - - [11\/Sep\/2019:21:44:55 +1200] \"GET \/awstatsicons\/clock\/hr7.png HTTP\/1.1\" 200 316 \"http:\/\/centos7-base\/awstats\/awstats.pl?config=www.zoyinc.com&amp;framename=mainright\" \"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko\/20100101 Firefox\/69.0\"<\/pre>\n<p>This is because the awstats config changes the format.<\/p>\n<h2>Now we need to install GeoIP<\/h2>\n<p>This is so we can get country info based on IP. So do the following:<\/p>\n<p style=\"padding-left: 30px;\">yum install perl-CPAN<\/p>\n<p>Then:<\/p>\n<p style=\"padding-left: 30px;\">perl -MCPAN -e &#8220;install Geo::IP::PurePerl&#8221;<\/p>\n<p>You will get various questions, I just hit &lt;Enter&gt; to accept defaults. Be warned it will seem long and take a little time!<\/p>\n<p>Then run:<\/p>\n<p style=\"padding-left: 30px;\">perl -MCPAN -e &#8220;install Geo::IP&#8221;<\/p>\n<p>It will take a little bit but not as long as first one.<\/p>\n<p>Look for the following line in the config file, \/etc\/awstats\/awstats.www.zoyinc.com.conf :<\/p>\n<p style=\"padding-left: 30px;\">#LoadPlugin=&#8221;geoip6 GEOIP_STANDARD \/pathto\/GeoIPv6.dat&#8221;<\/p>\n<p>Uncomment the line and change the path so it becomes:<\/p>\n<p style=\"padding-left: 30px;\">LoadPlugin=&#8221;geoip6 GEOIP_STANDARD <span style=\"background-color: #ffff99;\">\/usr\/share\/GeoIP\/GeoIP.dat<\/span>&#8220;<\/p>\n<p>Search for:<\/p>\n<p style=\"padding-left: 30px;\">LogFile=&#8221;\/var\/log\/httpd\/access_log&#8221;<\/p>\n<p>And change to:<\/p>\n<p style=\"padding-left: 30px;\">LogFile=&#8221;\/var\/log\/httpd<span style=\"background-color: #ffff99;\">24<\/span>\/access_log&#8221;<\/p>\n<p>Now do an initial run<\/p>\n<p style=\"padding-left: 30px;\">cd \/usr\/share\/awstats\/wwwroot\/cgi-bin<br \/>\nawstats\/awstats.pl?config=www.zoyinc.com<\/p>\n<p>Now you need to add a cron job as the root user. So run:<\/p>\n<p style=\"padding-left: 30px;\">crontab -e<\/p>\n<p>This will drop you into vi to edit the crontab. Add the following entry:<\/p>\n<p style=\"padding-left: 30px;\">0 0 * * * \/usr\/share\/awstats\/wwwroot\/cgi-bin\/awstats.pl -update -config=www.zoyinc.com &gt;\/dev\/null 2&gt;&amp;1<\/p>\n<p>This will run an update each day at midnight.<\/p>\n<h2>Copy AWStats data from old server to new<\/h2>\n<p>If you are migrating to a new server and want to bring your historical AWStats data then you just need to copy the data files.<\/p>\n<p>In the config file, \/etc\/awstats\/awstats.www.zoyinc.com.conf, the setting &#8220;DirData&#8221; describes where the data is stored. Just copy the old data from the old to the new. For me this was in:<\/p>\n<p style=\"padding-left: 30px;\">\/var\/lib\/awstats<\/p>\n<h2>You can get to AWStat at:<\/h2>\n<p><a  href=\"https:\/\/centos7-base\/awstats\/awstats.pl?config=www.zoyinc.com\">https:\/\/centos7-base\/awstats\/awstats.pl?config=www.zoyinc.com<\/a><\/p>\n<h1>Resources<\/h1>\n<p>Mystery Data: Upgrade Mariadb 5.5 to Mariadb 10.2 on Centos 7 VestaCP<br \/>\n<a  href=\"https:\/\/www.mysterydata.com\/upgrade-mariadb-5-5-to-mariadb-10-2-on-centos-7-vesta-cp\/\">https:\/\/www.mysterydata.com\/upgrade-mariadb-5-5-to-mariadb-10-2-on-centos-7-vesta-cp\/<\/a><\/p>\n<p>Red Hat: How to set up a LAMP stack on Red Hat Enterprise Linux 7<br \/>\n<a  href=\"https:\/\/developers.redhat.com\/blog\/2017\/03\/07\/how-to-set-up-a-lamp-stack-on-red-hat-enterprise-linux-7\/\">https:\/\/developers.redhat.com\/blog\/2017\/03\/07\/how-to-set-up-a-lamp-stack-on-red-hat-enterprise-linux-7\/<\/a><\/p>\n<p>TecAdmin: How To Install PHP 7.3, 7.2, 7.1 on CentOS\/RHEL 7.6<br \/>\n<a  href=\"https:\/\/tecadmin.net\/install-php7-on-centos7\/\">https:\/\/tecadmin.net\/install-php7-on-centos7\/<\/a><\/p>\n<p>Next Cloud: Installing PHP 7.2 on RHEL 7 and CentOS 7<br \/>\n<a  href=\"https:\/\/docs.nextcloud.com\/server\/15\/admin_manual\/installation\/php_72_installation.html\">https:\/\/docs.nextcloud.com\/server\/15\/admin_manual\/installation\/php_72_installation.html<\/a><br \/>\n&#8211; An excellent article on using software collections on CentOS 7 and PHP 7.2 on Apache httpd<\/p>\n<p>Red Hat: How can I make a Red Hat Software Collection persist after a reboot\/logout?<br \/>\n<a  href=\"https:\/\/access.redhat.com\/solutions\/527703\">https:\/\/access.redhat.com\/solutions\/527703<\/a><\/p>\n<p>Manage IQ: Developer setup guide Postgresql software collection<br \/>\n<a  href=\"http:\/\/manageiq.org\/docs\/guides\/developer_setup\/postgresql_software_collection\">http:\/\/manageiq.org\/docs\/guides\/developer_setup\/postgresql_software_collection<\/a><\/p>\n<p>Big Binary: Configure PostgreSQL to allow remote connection<br \/>\n<a  href=\"https:\/\/blog.bigbinary.com\/2016\/01\/23\/configure-postgresql-to-allow-remote-connection.html\">https:\/\/blog.bigbinary.com\/2016\/01\/23\/configure-postgresql-to-allow-remote-connection.html<\/a><\/p>\n<p>AWStats Documentation &#8211; Setups Page<br \/>\n<a  href=\"http:\/\/www.awstats.org\/docs\/awstats_setup.html\">http:\/\/www.awstats.org\/docs\/awstats_setup.html<\/a><\/p>\n<p>Plesk: How to confugure GeoIP plugin for AWStats<br \/>\n<a  href=\"https:\/\/support.plesk.com\/hc\/en-us\/articles\/115002097389\">https:\/\/support.plesk.com\/hc\/en-us\/articles\/115002097389<\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>Samba Config file &#8211; smb.conf<\/h2>\n<pre class=\"lang:default decode:true\">#\r\n# Sample Samba config file\r\n# \/etc\/samba\/smb.conf\r\n#\r\n# From Zoyinc.com\r\n#\r\n# Global parameters\r\n#\r\n[global]\r\n        domain master = No\r\n        guest account = sambaguest\r\n        load printers = No\r\n        local master = No\r\n        log file = \/var\/log\/samba\/log.%m\r\n        logon path = \/home\/sambaguest\r\n        logon script = startup.bat\r\n        map to guest = Bad User\r\n        max log size = 50\r\n        name resolve order = lmhosts bcast\r\n        os level = 99\r\n        server string = CentOS7 Base\r\n        time server = Yes\r\n        workgroup = CANTABRIAN\r\n        idmap config * : backend = tdb\r\n        create mask = 0774\r\n        directory mask = 0774\r\n        force create mode = 0774\r\n\r\n\r\n[public]\r\n        comment = Public\r\n        create mask = 0775\r\n        directory mask = 0775\r\n        dos filemode = Yes\r\n        fake directory create times = Yes\r\n        force create mode = 0000\r\n        force group = sambaguest\r\n        force user = sambaguest\r\n        fstype = FAT\r\n        guest ok = Yes\r\n        hide dot files = No\r\n        map archive = No\r\n        path = \/mnt\/public\r\n        read only = No\r\n\r\n\r\n[backup]\r\n        comment = Backups\r\n        create mask = 0775\r\n        directory mask = 0775\r\n        dos filemode = Yes\r\n        fake directory create times = Yes\r\n        force create mode = 0000\r\n        force group = backup\r\n        force user = backup\r\n        fstype = FAT\r\n        hide dot files = No\r\n        map archive = No\r\n        path = \/srv\/backup\r\n        read only = No<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In the post\u00a0CentOS 7 base VM for WordPress and MythTV I described how to create a base CentOS 7 VM. This post describes follows on from that post and describes the post installation tasks to make the VM a good solid base for me to run WordPress or MythTV. When setting up a Linux server [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":3879,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85,553,537,536,552,107,123,10],"tags":[576,555,556,295,539,538,298,574,158,554,6,575,561,333,560,307,108,93,297],"class_list":["post-3761","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apache","category-centos","category-mariadb","category-mysql","category-redhat","category-subversion","category-vmware","category-wordpress","tag-awstats","tag-centos","tag-centos7","tag-linux","tag-mariadb","tag-mysql","tag-mythtv","tag-postgres","tag-postgresql","tag-red-hat","tag-redhat","tag-samba","tag-scl","tag-smb","tag-software-collections","tag-subversion","tag-svn","tag-unix","tag-wordpress"],"_links":{"self":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts\/3761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3761"}],"version-history":[{"count":45,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts\/3761\/revisions"}],"predecessor-version":[{"id":3883,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts\/3761\/revisions\/3883"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/media\/3879"}],"wp:attachment":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3761"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}