Errors about a missing temporary folder, or updates that stop while downloading, often mean WordPress has nowhere to put its working files.
Normally it tries PHP’s system temp directory, then upload_tmp_dir from the PHP settings, then wp-content. On locked down hosting, or with a tiny /tmp, those can all disappoint. Pick your own:
define( 'WP_TEMP_DIR', '/var/www/example.com/tmp' );
Create the folder and give the PHP user write access:
mkdir -p /var/www/example.com/tmp
chown www-data: /var/www/example.com/tmp
chmod 750 /var/www/example.com/tmp
I’d put it outside the web root, as above, so nothing in it can be requested by a browser. Adjust the user name to whatever your PHP runs as.
WordPress uses the constant as given and doesn’t check that the folder exists or is writable, so a typo produces the same failures you started with. Test it by uploading an image and installing a small plugin.
It covers WordPress’s own temporary files. The temporary location PHP uses while receiving an upload is set by PHP itself, so a failure at that earlier stage needs upload_tmp_dir in php.ini. And with open_basedir restrictions in place, the new folder has to be on the allowed list.
Old files can accumulate there after interrupted updates, so glance at it now and then.
Further reading: WordPress developer docs: wp-config.php