majix
By:
majix

How can i connect Wordpress media library to one or multiple Block Storage(Volumes)?

July 13, 2016 2.1k views
Storage WordPress PHP MySQL Ubuntu

Hi,
The Block storage feature is awesome, i was one of the beta testers. I'm using Wordpress and i want to connect Media library or Uploads folder to one or multiple block storages i have created. I could do this buy linking folders in Ubuntu, but this just works for one volume. Is there any other way to do this that i don't know?

Thank you in advance

2 Answers

I'm not sure how you would be able to point the uploads folder at multiple volumes at once short of doing something like setting up a RAID array. I'm curious what you use case is?

If you want to move the location of the WordPress Media library and Uploads folder without using sysmlinks, you can define the location in your wp-config.php file. You can not use absolute paths though. So if the folder is located at /mnt/volume-nyc1-01/wp-uploads, you would set:

define('UPLOADS', '../../../../mnt/volume-nyc1-01/wp-uploads');

Some other points to consider are that you need to ensure the folder is owned by the webserver user. On Ubuntu, this would be www-data To do so, run:

  • sudo chown www-data:www-data /mnt/volume-nyc1-01/wp-uploads
  • Thank you very much for the other option you mentioned.
    I was just thinking for the future plans. Like separating Video volume from Zip files volume (or other formats) for better categorizing and also not to make a volume full in just a year or less (because of the maximum 16T limit).
    I think the symlink is a more reasonable way for linking one volume for now until someone create a good plugin for this purpose.

    Thank you

  • I was trying to relocate my uploads file to a volume using this suggestion

    but when I uploaded an image into the media library it tried to make the image URL

    domain.com/wp-content/../../../../mnt/volume-nyc1-01/wp-uploads/filename.jpg which of course was broken

    Does wordpress allow you to move up directories like this?

    • You needed to specify the whole path to the volume directory. To fix run the commands below

      cd /path/to/wp-content/
      rm uploads
      ln -s /mnt/volume-nyc1-01/wp-uploads/ uploads
      

      First command changes you to the site wp-content directory.
      Second command is used to remove the uploads symlink, if you don't have a symlink created then skip it. Do not run the command with -r.
      Third command creates the symlink, it should work now.

Hey everyone,

Just want to add for other folks that may help, if your using this article which is awesome so kudos guys, and your WordPress install whether one click or LAMP stack, your uploads folder will not exist until you upload a file to it or create it.

Hope that helps, Thanks for info above again!

Have another answer? Share your knowledge.