Apache not serving some content from network share
Solution 1:
Do not symlink /media/data
to /var/www/server
but use bindfs instead:
# Install bindfs
sudo apt install bindfs
# Stop apache
sudo systemctl stop apache2
# Remove symlink
sudo rm /var/www/server
# Create dir
sudo mkdir /var/www/server
# Bind mount
sudo bindfs -u www-data -g www-data /media/data /var/www/server
# Start apache
sudo systemctl start apache2
If the served webpage is static or uses a database as backend you can also add the -r
option to the bindfs call, to make the mount read-only.
Add an entry to /etc/fstab
to automount at boot:
/media/data /var/www/server fuse.bindfs user=www-data,force-group=www-data 0 0
Most webservers expect the files to be owned by www-data
and need certain capabilities of the filesystem that a samba mount does not provide. A symlink does not solve those issues. The bindfs
solution provides all those requirements to the webserver by adding another, transparent layer of abstraction. FWIW, I would consider the bindfs
approach to be the much cleaner solution.