Hi all
I have an Alpine container on Proxmox that we use as a Zabbix Proxy. On it there is a PHP script (no web server). When I ssh in with my normal user account and run the PHP from cli, it works great. When I su to user root (for testing) it works fine. But when I su to user zabbix, I get:
Class “PhpOffice\PhpSpreadsheet\Spreadsheet” not found
This a problem because it will be Zabbix that triggers the script once a day. I get the same error whether zabbix triggers the script, or I trigger it from cli.
I have other ash, php, and python scripts on the proxy that run just fine when Zabbix triggers them.
The require statements at the top of the script don’t throw an error:
require $folder . “/phpSpreadsheet/vendor/autoload.php”;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
The error happens farther down when it creates a new spreadsheet in memory: $spreadsheet = new Spreadsheet();
I had to use Composer to install the phpSpreadsheet library. I was getting a bunch of file & folder permissions errors but I’m certain I’ve covered that as this is not a file permissions error. I even reran composer as the zabbix user to check for permissions.
From googling I’ve found that the zabbix user is a “service account” as opposed to a user account. I used “su zabbix -s /bin/ash” get a cli going so I could test running the script directly. Running env shows that the Zabbix user’s HOME directory is “/dev/null” Beyond that I’m not sure what differences there are between the accounts, or what would prevent a php class from loading.
Any help is welcome. Thanks.