Whoops, the web server could not write required files to the filesystem

Ive Installed it with the Tutorial “https://computingforgeeks.com/how-to-install-librenms-on-rhel-centos-8/
Entering the Commands below changes nothing.

Where is my fault?

Centos 8 New Server only Librenms installed.

https://URL/validate/ Output:

Whoops, the web server could not write required files to the filesystem.

Running the following commands will fix the issue most of the time:

sudo chown -R librenms:librenms /opt/librenms
sudo setfacl -d -m g::rwx /opt/librenms/bootstrap/cache /opt/librenms/storage /opt/librenms/logs /opt/librenms/rrd
sudo chmod -R ug=rwX /opt/librenms/bootstrap/cache /opt/librenms/storage /opt/librenms/logs /opt/librenms/rrd

If using SELinux you may also need:

semanage fcontext -a -t httpd_sys_rw_content_t ‘/opt/librenms/bootstrap/cache(/.)?’
semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/storage(/.
)?’
semanage fcontext -a -t httpd_sys_rw_content_t ‘/opt/librenms/logs(/.)?’
semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/rrd(/.
)?’
restorecon -RFv /opt/librenms

tail -f /opt/librenms/logs/librenms.log (Refresh of the Validate URL)

[2020-06-19 13:20:45] production.ERROR: file_put_contents(/opt/librenms/storage/framework/sessions/lp0EoiuRq8e77Q0pbKf9e7OGXsDSciRgEC3d1adq): failed to open stream: Permission denied {“exception”:"[object] (ErrorException(code: 0): file_put_contents(/opt/librenms/storage/framework/sessions/lp0EoiuRq8e77Q0pbKf9e7OGXsDSciRgEC3d1adq): failed to open stream: Permission denied at /opt/librenms/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:133)
[stacktrace]
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, ‘file_put_conten…’, ‘/opt/librenms/v…’, 133, Array)
#1 /opt/librenms/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(133): file_put_contents(’/opt/librenms/s…’, ‘a:4:{s:6:"_toke…’, 2)
#2 /opt/librenms/vendor/laravel/framework/src/Illuminate/Session/FileSessionHandler.php(83): Illuminate\Filesystem\Filesystem->put(’/opt/librenms/s…’, ‘a:4:{s:6:"_toke…’, true)
#3 /opt/librenms/vendor/laravel/framework/src/Illuminate/Session/Store.php(129): Illuminate\Session\FileSessionHandler->write(‘lp0EoiuRq8e77Q0…’, ‘a:4:{s:6:"_toke…’)
#4 /opt/librenms/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(170): Illuminate\Session\Store->save()
#5 /opt/librenms/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(65): Illuminate\Session\Middleware\StartSession->saveSession(Object(Illuminate\Http\Request))
#6 /opt/librenms/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#7 /opt/librenms/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#8 /opt/librenms/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#9 /opt/librenms/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#10 /opt/librenms/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#11 /opt/librenms/app/Http/Middleware/CheckInstalled.php(46): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#12 /opt/librenms/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): App\Http\Middleware\CheckInstalled->handle(Object(Illuminate\Http\Request), Object(Closure))
#13 /opt/librenms/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#14 /opt/librenms/vendor/laravel/framework/src/Illuminate/Routing/Router.php(683): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#15 /opt/librenms/vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#16 /opt/librenms/vendor/laravel/framework/src/Illuminate/Routing/Router.php(624): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#17 /opt/librenms/vendor/laravel/framework/src/Illuminate/Routing/Router.php(613): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#18 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(170): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#19 /opt/librenms/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#20 /opt/librenms/vendor/darkghosthunter/larapoke/src/Http/Middleware/LarapokeGlobalMiddleware.php(20): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#21 /opt/librenms/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): DarkGhostHunter\Larapoke\Http\Middleware\LarapokeGlobalMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#22 /opt/librenms/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(58): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#23 /opt/librenms/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle(Object(Illuminate\Http\Request), Object(Closure))
#24 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#25 /opt/librenms/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#26 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#27 /opt/librenms/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#28 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#29 /opt/librenms/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#30 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(63): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#31 /opt/librenms/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#32 /opt/librenms/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#33 /opt/librenms/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#34 /opt/librenms/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#35 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#36 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#37 /opt/librenms/html/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#38 {main}

Why not use the official and recommended documentation so that you’ve got a known baseline?

https://docs.librenms.org/Installation/Install-LibreNMS/

1 Like

Ive checked all Steps in the official docs bute i still see the following problems:

Setup validate.php with root or librenms user makes no difference:
[librenms@nms]# ./validate.php

====================================

Component Version
LibreNMS 1.69-1-gbc02ab3f6
DB Schema Not Connected (0)
PHP 7.2.24
Python 3.6.8
MySQL ?
RRDTool 1.7.0
SNMP NET-SNMP 5.8
OpenSSL

====================================

[OK] Composer Version: 2.0.7
[OK] Dependencies up-to-date.
Could not connect to database, check logs/librenms.log.

And i still see the same permission problem like on the beginning.

[2020-11-xx xx:xx:xx] production.ERROR: file_put_contents(/opt/librenms/storage/framework/sessions/neuV8YisDoz0GY36NyxyIXACY1vvrNByBeVrfwQg): failed to open stream: Permission denied {“exception”:"[object] (ErrorException(code: 0): file_put_contents(/opt/librenms/storage/framework/sessions/neuV8YisDoz0GY36NyxyIXACY1vvrNByBeVrfwQg): failed to open stream: Permission denied at /opt/librenms/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:135)
[stacktrace]

Any Idea ?

Thanks a lot!

SELINUX was the Problem. Enforce > Disable and it works.

But the DB Issue is still present:
[previous exception] [object] (PDOException(code: 1045): SQLSTATE[HY000] [1045] Access denied for user ‘librenms’@‘localhost’ (using password: NO) at /opt/librenms/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27)

Check your database setting. Looks like there is set something wrong.

Steps ive done:

  • DROP of Database and User in Maria DB.
  • Create new:
    CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
    CREATE USER ‘librenms’@‘localhost’ IDENTIFIED BY ‘password’;
    GRANT ALL PRIVILEGES ON librenms.* TO ‘librenms’@‘localhost’;
    FLUSH PRIVILEGES;
    exit

Result:
./validate.php

Component Version
LibreNMS 1.69-1-gbc02ab3f6
DB Schema Not Connected (0)
PHP 7.3.20
Python 3.6.8
MySQL ?
RRDTool 1.7.0
SNMP NET-SNMP 5.8
OpenSSL
====================================

[OK] Composer Version: 2.0.7
[OK] Dependencies up-to-date.
Could not connect to database, check logs/librenms.log.

in librenms.log no new loggs.

  • in GUI " You have not quite finished yet!
    First, you need to validate your install and fix any issues.
    Unbenannt|543x500

  • After Drop of the Database all Tables are created new via GUI /install as expected.

  • System: Centos 8 MariaDB PHP7.3 Nginx.

  • Looks that the .env oder .config.php is not used.
    Where should i enter the DB Account and Password? At the Moment its setup in the config.php and not in the .env.!

Any Idea?

Have you entered a password for the LibreNMS user?

If you just copy n paste, the. Your password is ‘password’.:roll_eyes:

Yes ive entered a very simple password to make shure that its correct.

Can you connect with LibreNMS user via mysql cli?

Yes:

[user@librenms]# mysql -u librenms -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 492
Server version: 10.3.17-MariaDB MariaDB Server

Copyright © 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]> use librenms;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [librenms]> show tables;
±--------------------------+
| Tables_in_librenms |
±--------------------------+
| access_points |
| alert_device_map |
| alert_group_map |
| alert_location_map |
| alert_log |
| alert_rules |
| alert_schedulables |
| alert_schedule |
| alert_template_map |
| alert_templates |
| alert_transport_groups |
| alert_transport_map |
| alert_transports |
| alerts |
| api_tokens |
| application_metrics |
| applications |
| authlog |
| availability |
| bgpPeers |
| bgpPeers_cbgp |
| bill_data |
| bill_history |
| bill_perms |
| bill_port_counters |
| bill_ports |
| bills |
| cache |
| cache_locks |
| callback |
| cef_switching |
| ciscoASA |
| component |
| component_prefs |
| component_statuslog |
| config |
| customers |
| customoids |
| dashboards |
| dbSchema |
| device_graphs |
| device_group_device |
| device_groups |
| device_outages |
| device_perf |
| device_relationships |
| devices |
| devices_attribs |
| devices_group_perms |
| devices_perms |
| entPhysical |
| entPhysical_state |
| entityState |
| eventlog |
| graph_types |
| hrDevice |
| ipsec_tunnels |
| ipv4_addresses |
| ipv4_mac |
| ipv4_networks |
| ipv6_addresses |
| ipv6_networks |
| juniAtmVp |
| links |
| loadbalancer_rservers |
| loadbalancer_vservers |
| locations |
| mac_accounting |
| mefinfo |
| mempools |
| migrations |
| mpls_lsp_paths |
| mpls_lsps |
| mpls_saps |
| mpls_sdp_binds |
| mpls_sdps |
| mpls_services |
| mpls_tunnel_ar_hops |
| mpls_tunnel_c_hops |
| munin_plugins |
| munin_plugins_ds |
| netscaler_vservers |
| notifications |
| notifications_attribs |
| ospf_areas |
| ospf_instances |
| ospf_nbrs |
| ospf_ports |
| packages |
| pdb_ix |
| pdb_ix_peers |
| perf_times |
| plugins |
| poller_cluster |
| poller_cluster_stats |
| poller_groups |
| pollers |
| ports |
| ports_adsl |
| ports_fdb |
| ports_nac |
| ports_perms |
| ports_stack |
| ports_statistics |
| ports_stp |
| ports_vlans |
| processes |
| processors |
| proxmox |
| proxmox_ports |
| pseudowires |
| route |
| sensors |
| sensors_to_state_indexes |
| services |
| session |
| slas |
| state_indexes |
| state_translations |
| storage |
| stp |
| syslog |
| tnmsneinfo |
| toner |
| transport_group_transport |
| ucd_diskio |
| users |
| users_prefs |
| users_widgets |
| vlans |
| vminfo |
| vrf_lite_cisco |
| vrfs |
| widgets |
| wireless_sensors |
±--------------------------+
135 rows in set (0.000 sec)

MariaDB [librenms]> show grants;
±----------------------------------------------------------------------------------------------------------------+
| Grants for librenms@localhost |
±----------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON . TO ‘librenms’@‘localhost’ IDENTIFIED BY PASSWORD 'XYZ’ |
| GRANT ALL PRIVILEGES ON librenms.
TO ‘librenms’@‘localhost’ |
±----------------------------------------------------------------------------------------------------------------+
2 rows in set (0.000 sec)

MariaDB [librenms]>

What’s in your config.php regarding the DB

/ <?php

Have a look in misc/config_definitions.json for examples of settings you can set here. DO NOT EDIT misc/config_definitions.json!

Database config

$config[‘db_host’] = ‘localhost’;
$config[‘db_user’] = ‘librenms’;
$config[‘db_pass’] = ‘********’;
$config[‘db_name’] = ‘librenms’;

// This is the user LibreNMS will run as
//Please ensure this user is created and has the correct permissions to your install
$config[‘user’] = ‘librenms’;

This should only be set if you want to force a particular hostname/port

It will prevent the web interface being usable form any other hostname

$config[‘base_url’] = “/”;

Enable this to use rrdcached. Be sure rrd_dir is within the rrdcached dir

and that your web server has permission to talk to rrdcached.

#$config[‘rrdcached’] = “unix:/var/run/rrdcached.sock”;

Default community

$config[‘snmp’][‘community’] = array(‘public’);

Authentication Model

$config[‘auth_mechanism’] = “mysql”; # default, other options: ldap, http-auth
#$config[‘http_auth_guest’] = “guest”; # remember to configure this user if you use http-auth

List of RFC1918 networks to allow scanning-based discovery

#$config[‘nets’][] = “10.0.0.0/8”;
#$config[‘nets’][] = “172.16.0.0/12”;
#$config[‘nets’][] = “192.168.0.0/16”;

Uncomment the next line to disable daily updates

#$config[‘update’] = 0;

Number in days of how long to keep old rrd files. 0 disables this feature

$config[‘rrd_purge’] = 0;

Uncomment to submit callback stats via proxy

#$config[‘callback_proxy’] = “hostname:port”;

Set default port association mode for new devices (default: ifIndex)

#$config[‘default_port_association_mode’] = ‘ifIndex’;

Enable the in-built billing extension

$config[‘enable_billing’] = 1;

Enable the in-built services support (Nagios plugins)

$config[‘show_services’] = 1;
$config[“fping”] = “/usr/sbin/fping”;
$config[“rrdcached”] = “unix:/var/run/rrdcached/rrdcached.sock”;
$config[“update_channel”] = “release”;
$config[“enable_syslog”] = 1;

Any Idea or mistake in the config.php?