Trying out latest FusionPBX - Fatal error: Uncaught TypeError: fwrite():

question

New Member
Mar 30, 2026
10
0
1
64
Latest install of FusionPBX with FreeSWITCH v1.11.0 on new AWS EC2 instance of Debian 13. If I try to save anything in Advanced > Variables it gives:

Fatal error: Uncaught TypeError: fwrite(): Argument #1 ($stream) must be of type resource, bool given in /var/www/fusionpbx/resources/switch.php:329 Stack trace: #0 /var/www/fusionpbx/resources/switch.php(329): fwrite() #1 /var/www/fusionpbx/app/vars/var_edit.php(148): save_var_xml() #2 {main} thrown in /var/www/fusionpbx/resources/switch.php on line 329

Permissions of vars.xml look correct:
-rw-r--r-- 1 www-data www-data 4668 May 22 11:29 /etc/freeswitch/vars.xml
 
I am getting the same error as well
I found the problem. In switch.php line 293, fopen fails because the directory is read only to FusionPBX. The file permissions are OK but Systemd security is interfering.

I have reported this to support to get an official solution.
 
For those need a quick fix, update /var/www/fusionpbx/resources/switch.php line 293 replacing "w" to "rw":
PHP:
$fout = fopen($switch_conf_dir."/vars.xml","rw");

No success with w+ or r+

Code:
- Application
  - version: 5.5.10
  - branch: 5.5
  - path: /var/www/fusionpbx
- PHP
  - version: 8.2.31
  - apcu enabled: false
- Switch
  - version: 1.11.0
- Database
  - name: PostgreSQL
  - version: 17.10
- Operating System
  - name: Debian
  - version: 12
 
Last edited:
  • Like
Reactions: ps1
error vanishes but it seems the variables are not loaded. can someone verify this?
i have problem to use a freshly defined VPN-IP variable in internal SIP-Profile.
deleted cache even on filesystem and restartet, the variable is not set (if a hardcode the ip in SIP-Profile instead of $$(myip) it works though
 
This issue happened when the maintainer of the sury repo updated permissions for the systemd PHP FPM service. This affects all versions of PHP FPM that are pulled from the sury repo since mid May 2026. This was a security update to the systemd service file. It made certain directories read only by default. For example /etc/freeswitch and /usr/share/freeswitch and others.

php8.4 (8.4.21-2) unstable; urgency=medium

* The systemd unit file has been hardened. Extra options from
sapi/fpm/php-fpm.service.in has been used:

ProtectSystem=full
PrivateDevices=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectControlGroups=true
RestrictRealtime=true
RestrictAddressFamilies=AF_INET AF_INET6 AF_NETLINK AF_UNIX
RestrictNamespaces=true

This should work in the default environments, but you might need
to modify the systemd unit file if you are using less standard
FPM configuration.

-- Ondřej Surý <ondrej@debian.org> Sun, 10 May 2026 19:38:37 +0200

To solve the issue you have to update the php fpm service file. With the latest FusionPBX 5.5 and master branch. All you have to do is update the source code to latest on either of those branches. Then it will update the php fpm service file to add the directories that need the ReadWritePaths exception.

You can use git status to check the branch you are on.
git status

This will update the php fpm service adding ReadWritePaths exception if needed.
cd /var/www/fusionpbx
git pull
php core/upgrade/upgrade.php
 
  • Like
Reactions: question