Question

Moving wp-content to block storage volume

Because I’m running out of space, I’m trying to move my wp-content folder to a block storage volume. (from /var/www/html/ to /mnt/folder)

I tried creating a symlink from the wp-content to the new wp-content folder but that doesn’t seem to work. Then I tried using the following code in the wp-config file:

    //define('WP_CONTENT_DIR', '../../../../mnt/folder/wp-content');
    //define('WP_CONTENT_URL', 'https://site/wp-content');
    //define('WP_PLUGIN_DIR', '../../../../folder/content/plugins'); 
    //define('WP_PLUGIN_URL', 'https://site/wp-content/plugins');
    //define( 'PLUGINDIR', '../../../../mnt/folder/content/plugins');

It seemed to work, for the most part. But when I enable any plugins I get an MSQL warning saying there are too many connections. I get locked out of the admin dashboard but I can fix it by renaming the plugins folder(to disable the plugins). I found some information here: https://www.digitalocean.com/community/questions/how-can-i-connect-wordpress-media-library-to-one-or-multiple-block-storage-volumes

I’d really appreciate some help.


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.

Accepted Answer

@jtittle I’m not sure if you’ll agree with this - please alert @joostvanhoutte if not

@joostvanhoutte I don’t think DO has an option like that, since that’s what BS is there for.

First things first. Take a snapshot for your droplet, so you can revert if everything goes horribly wrong :)

Move your uploads so we don’t mess with current data:

mv /var/www/html/wp-content/uploads /var/www/html/wp-content/uploads-old

Unmount the current mount:

umount /mnt/bs-name-mount

Create the new empty uploads folder and set the correct permissions. I’m guessing you’re running as www-data:

mkdir /var/www/html/wp-content/uploads
chown www-data:www-data /var/www/html/wp-content/uploads

Edit fstab and mount directly to /var/www/html/wp-content/uploads instead of /mnt/bs-name-mount:

nano /etc/fstab

Remount the new mount point:

mount -a

Copy the uploads-old to the new BS mount:

cp -Rp /var/www/html/wp-content/uploads-old/* /var/www/html/wp-content/uploads/

Please reboot the server to confirm that the fstab is mounting correctly on reboot before getting rid of the uploads-old. When you’ve confirmed that you’re running on the new BS mount (upload a new file and see where it’s placed), you can safely remove the uploads-old folder:

rm -RI /var/www/html/wp-content/uploads-old

Hi @joostvanhoutte

May I recommend that you do not move the entire wp-content folder, because it will slow down your site.

You should only be moving the uploads folder, since it doesn’t contain files that require to be loaded in memory often (like the theme and plugins).

Something like this should be enough:

define( 'UPLOADS', '/mnt/folder/uploads');

@hansen Hello, i’m stuck at step:

<^>Edit fstab and mount directly to /var/www/html/wp-content/uploads instead of /mnt/bs-name-mount:

nano /etc/fstab<^>

how can i edit this, i don’t know what to do!

Example link

Try DigitalOcean for free

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

Sign up

Become a contributor for community

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

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.