bind mount to get web server link to files outside Documentroot device
Wanting to give access at home to some files of use for home activities, I set up a web server (I tried both nginx and apache2). However, a symlink to the files of interest pointed outside the current device. I was able to point to files in my home directory from a symlink in /var/www/html without difficulty. (/home is on same device as /var/www)
I tried a number of configuration settings in the .conf files, including “alias” and various FollowSymLinks tries, without success.
At the April 4 linux-ottawa meeting, Alex Pilon suggested a bind mount, and this works.
Directory /var/www/html/ contains files and symlinks There is a directory tto18 with 755 permissions and root ownership.
sudo mount -o bind /media/john/Rebecca /var/www/html/tto18
allows local users (on local router, and therefore hopefully inside the firewall) to access my machine as “john-j6-18.local” and see this directory, which points to a disk that is attached.
To get this set up when my machine boots, I tried adding the command “/home/john/bin/bmreb” to the Startup Items in the Linux Mint Control Centre. “bmreb” is a file with contents
#!/bin/bash # bmreb -- bind mount rebecca mount -o bind /media/john/Rebecca /var/www/html/tto18
It is owned by root and has 755 permissions. Rebooting, I found that the bind mount was not active. In Linux Mint 19.1, it is now necessary to use systemd to start such items as indicated in https://forums.linuxmint.com/viewtopic.php?t=275464 which gives a tutorial. I followed this and have a working startup.