gerardop
By:
gerardop

Why volume is only sudo writeable? / pointing my media public folder in Nginx to the attached volume

January 23, 2017 360 views
DigitalOcean Block Storage Ubuntu

I have create a block storage volume attached to my Ubuntu droplet following the tutorial. It seems to work but it is only writable with sudo commands.

Also I'd like to point my public/media folder in Nginx to this attached volumen. What is the best way to do it, symbolic link, location?

Thanks
Gerardo

1 Answer

@gerardop

You should be able to use either the root user or a sudo user, if you've created one. The root user has global permissions and should be able to read & write from any location.

If you're not able to write to a file or directory on the block storage using a normal, non-root, non-sudo user (i.e. www-data), it'd be because the user you're trying to read or write with doesn't have proper permissions to do so and the device (if you used DigitalOcean's guide) is owned by root.

You'd need to change ownership, or chown the files and directories so that they are owned by the user you're trying to use to read and write with before that user will be allowed to do so.

You can do this like so:

chown user:user /path/to/directory

or

chown user:user /path/to/file.txt

or if you want to do it recursively (for when you have multiple directories and files in one directory and need them all to be owned by a specific user:

chown -R user:user /path/to/directory

The above command will change ownership on ALL files and directories under ./directory.

Have another answer? Share your knowledge.