Logs not writeable after fresh install on CentOS 7

I have a fresh install of CentOS 7 (Core). I followed the instructions at https://docs.librenms.org/Installation/Installation-CentOS-7-Apache/ to configure LibreNMS, however, after going through the initial WebUI setup, I can’t login due to logs not being writeable…

The message text is:
### Running the following commands will fix the issue most of the time:

### Cannot write to log file: "/opt/librenms/logs/librenms.log"

Make sure it exists and is writable, or change your LOG_DIR setting.

#### If using SELinux you may also need:

semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/logs/librenms.log(/.*)?'

restorecon -RFv /opt/librenms/logs/librenms.log

I am not sure how to resolve this - the log file exists. An ls -li for the log folder shows the following:

total 4
34109138 -rwxrwxr--. 1 librenms librenms 801 Mar 20 13:50 librenms.log

I tried to run the commands, but semanage wasn’t found… I haven’t changed any settings. The only part of the tutorial I missed was the “Configure snmpd” bit, as snmpd.conf didn’t contain “RANDOMSTRINGGOESHERE”.

Running validate.php produces the following output:
[OK] Composer Version: 1.8.4
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct
[WARN] You have not added any devices yet.
[FIX]:
You can add a device in the webui or with ./addhost.php
[WARN] Your install is over 24 hours out of date, last update: Fri, 01 Mar 2019 00:00:01 +0000
[FIX]:
Make sure your daily.sh cron is running and run ./daily.sh by hand to see if there are any errors.

Warning 1: Correct, I haven’t added any devices
Warning 2: Not sure what this is or the cron job that isn’t running? (I ran the command to create the job as per the instructions); but it’s not showing up as a fail - is this alright to leave? If not, how would I resolve this.

Thanks

Can you post output of

php -v
sestatus
getfacl /opt/librenms/logs/librenms.log

The output of the above is:

Thanks

I think that problem will be selinux related, since your current mode is enforcing, you could prove it by setting to permissive or disabling (you will need to reboot after changing selinux settings).
#https://linuxize.com/post/how-to-disable-selinux-on-centos-7/

If you want to keep selinux enforcing then you will need to run that semanage command, (or work out why that semanage command isn’t working).

1 Like

With SELinux in permissive mode, this error disappeared. As setenforce 0 is only good for the session, I had to find out why the semanage command wasn’t working…

semanage is provided in the policycoreutils-python package… which wasn’t installed!

After installing this (yum install policycoreutils-python), I was able to run the initially suggested commands ( semanage fcontext -a -t httpd_sys_rw_content_t ‘/opt/librenms/logs/librenms.log(/.*)?’ and restorecon -RFv /opt/librenms/logs/librenms.log).

After a reboot, LibreNMS is fully accessible :slight_smile:

Thanks for pointing me in the right direction :+1:

1 Like