I have a website hosted locally on an Apache2 at my Ubuntu machine, (Kubuntu 20.04). There are some audio files on a folder at a USB stick at the path /media/MyUserName/KINGSTON/audio while the public web folder that I want to create the Symlink on it is /home/MyUserName/www/site/web
In other words, I want to create a symlink to audio at web.
I have tried:
# on /home/MyUserName/www/site/web ...
ln -s /media/MyUserName/KINGSTON/audio audio
The symbolic link has been created successfully. However, the audio folder is not accessible by the web server, so I have tried to change the group of the symlink at the web folder to be www-data by:
sudo chgrp www-data audio
However, I got the following error:
chgrp: changing group of ‘audio’: Operation not permitted
I also tried to execute the chgrp from the USB stick path @ /media/MyUserName/KINGSTON but I got the same error.
How could I make this symlink accessible by the web server? or How to change its group?
Update
Yesterday I used the following command to mount the USB stick to a local directory and then creating the Symlink to that local directory. It worked fine and I could able to allow Apache access to that directory. However, after restarting today, the issue returned to its original state.
sudo mount -t vfat -o rw,uid=www-data,gid=www-data /dev/sdc1 /home/MyUserName/kingstone
Also today the usb stick becomes /dev/sdb1 instead of /dev/sdc1. So I had to modify it in the command above.
Now the question is: How could I mount that USB stick automatically to /home/MyUserName/kingstone?
>Solution :
See man fstab and your current file /etc/fstab for more details.
The first field is where to use
UUID=...
The second field describes the mountpoint
The third field describes the filesystem
The fourth field is where to put the options, separated by commas, corresponding to your mount command line
rw,uid=www-data,gid=www-data
The fifth field for an external drive (your USB stick) can contain a zero: 0
The sixth field for an external drive (your USB stick) can contain a zero: 0 but if you want it to be checked regularly, you can put 2 there (and use tune2fs to set the checking interval if an ext4 file system).