How can one ensure that the www-data user has access to a mounted directory in Apache?

To ensure that the www-data user has access to a mounted directory in Apache, you can set the appropriate permissions on the mounted directory. This can be done by changing the ownership of the directory to the www-data user and group, and also setting the correct permissions to allow read, write, and execute access.

// Change ownership of the mounted directory to www-data user and group
exec('sudo chown -R www-data:www-data /path/to/mounted/directory');

// Set permissions to allow read, write, and execute access for www-data user
exec('sudo chmod -R 755 /path/to/mounted/directory');