ZipArchive::close(): Failure to create temporary file in AWS EC2 Linux

Need Absolute path to save excel file in AWS Ec2 Linux for PHPExcel.

$excel_path = '/var/www/html/MyProject/public/SubmittedSheets/'.$userId.'-'.uniqid().'.xlsx';
$objWriter->save($excel_path); 

I solved it on my Mac OS system by simply uncommenting the line

;sys_temp_dir = "/tmp"

in php.ini, i.e. changing it to

sys_temp_dir = "/tmp"

Directory where the temporary files should be placed. Defaults to the system default (see sys_get_temp_dir)

Not sure which directory it tried to use as default though, possibly /var/tmp, which my Homebrew PHP installation doesn't seem to have permission to write to.