Question

How do I access the space on an attached volume from my webroot?

I have some large image directories for a webcam site. The directories are in this path /var/www/boulderflatironcam.com/public_html/ on the server. The web root was laid out on the droplet’s 40GB disk and I was expecting the block storage to just extend this disk. I started rsyncing files from another server and filled up the main disk. It looks like it comes up as an attached storage device. Do I need to move the whole web directory to the new storage or is there a way to put just certain directories on the block storage? Or, is there a way to just have the block storage extend the basic server disk?

Show comments

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Andrew SB
DigitalOcean Employee
DigitalOcean Employee badge
August 30, 2016
Accepted Answer

It’s is also possible to do this using Nginx’s simularly named alias directive. Again, let’s say your storage volume is mounted at /mnt/volume-nyc1-01 and that you want http://example.com/images to be served from the volume. First, you would need to create a directory on the volume that you can give ownership to the www-data user. E.g:

mkdir /mnt/volume-nyc1-01/images
sudo chown -R www-data:www-data /mnt/volume-nyc1-01/images

Then you’ll need to edit your Nginx’s configuration. By default, that is found at /etc/nginx/sites-enabled/default. Now add an alias directive pointing /images to /mnt/volume-nyc1-01/images:

        location /images/ {
                alias /mnt/volume-nyc1-01/images/;
        }

Finally, restart Apache for the changes to take effect:

sudo service nginx restart

Hi All, We have followed this documentation, unfortunately we are not able to connect volume that we have created from Snapshot from Droplet.

When we tried the following command which is giving following result. ls -lsh 64K drwxrwsr-x 2 www-data www-data 60K Apr 1 04:25 payum 0 lrwxrwxrwx 1 www-data www-data 27 Jun 3 2018 public -> /mnt/volumes-ams3/public/

We would like to connect that public folder to the volume that we have created recently. mnt/volumes-ams3 was created to used in different Droplet.

How can we change it to point to our volume ?

Appreciate your help.

Andrew SB
DigitalOcean Employee
DigitalOcean Employee badge
August 30, 2016

You can use Apache’s Alias directive to point a path to a specific directory outside of your web root. For example, let’s say your storage volume is mounted at /mnt/volume-nyc1-01 and that you want http://example.com/images to be served from the volume. First, you would need to create a directory on the volume that you can give ownership to the www-data user. E.g:

mkdir /mnt/volume-nyc1-01/images
sudo chown -R www-data:www-data /mnt/volume-nyc1-01/images

Then you’ll need to edit your Apache configuration. By default, that is found at /etc/apache2/sites-enabled/000-default.conf. Now add an Alias directive pointing /images to /mnt/volume-nyc1-01/images:

        Alias /images /mnt/volume-nyc1-01/images
        <Directory /mnt/volume-nyc1-01/images>
                Require all granted
        </Directory>

Finally, restart Apache for the changes to take effect:

sudo service apache2 restart

You can find out more details about how Block Storage volumes work in this tutorial: https://www.digitalocean.com/community/tutorials/how-to-use-block-storage-on-digitalocean

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel