How can the "chown" command be used to address file ownership issues in PHP scripts?
When running PHP scripts, file ownership issues may arise if the script needs to write to files that are owned by a different user. To address this, the "chown" command can be used to change the ownership of the files to match the user running the PHP script. By changing the ownership of the files, the PHP script will have the necessary permissions to write to them.
// Change ownership of a file to match the user running the PHP script
$file = 'example.txt';
$user = 'www-data'; // User running the PHP script
// Use chown command to change ownership
exec('chown ' . $user . ' ' . $file);