imagettftext cannot open font file
You could try to insert:
putenv('GDFONTPATH=' . realpath('.'));
in front of the first imagettftext
, just to make sure it is no path issue.
UPDATE
In case you are using font caches like fc-cache
, don't forget to refresh it, e.g.:
sudo fc-cache -f -v