How to Give a Wp Website User an Upload Space

Introduction

DigitalOcean Spaces is an object storage service that can be used to shop big amounts of diverse, unstructured data. WordPress sites, which often include prototype and video assets, can be good candidates for object storage solutions. Using object storage for these types of static resources can optimize site performance by freeing up space and resource on your servers. For more than information about object storage and WordPress check out our tutorial on How To Back Upwardly a WordPress Site to Spaces.

In this tutorial, we will use a WordPress plugin that works directly with DigitalOcean Spaces to use it as the primary nugget shop. The DigitalOcean Spaces Sync plugin routes the data of our WordPress media library to Spaces and provides you with diverse configuration options based on your needs, streamlining the process of using object storage with your WordPress example.

Prerequisites

This tutorial assumes that yous have a WordPress instance on a server also every bit a DigitalOcean Infinite. If you lot do not have this set upward, yous can complete the following:

  • One Ubuntu 16.04 server, fix upwardly following our Initial Server Setup with Ubuntu 16.04 tutorial.
  • A LAMP stack installed on your server, following our tutorial on How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 16.04.
  • WordPress installed on your server, following our tutorial on How To Install WordPress with LAMP on Ubuntu 16.04.
  • A DigitalOcean Infinite and API central, created by following How To Create a DigitalOcean Space and API Fundamental.
  • WP-CLI installed by following these instructions.

With these prerequisites in place, we're ready to begin using this plugin.

Modifying WordPress Permissions

Throughout this tutorial, we will be working with the wp-content/uploads folder in our WordPress projection, so it is important that this folder exists and has the correct permissions. Y'all can create information technology with the mkdir control using the -p flag in order to create the folder if it doesn't exist, and avoid throwing an mistake if it does:

                      
  1. sudo mkdir -p /var/www/html/wp-content/uploads

You lot can now set permissions on the binder. First, set the ownership to your user (nosotros volition use sammy hither, simply be sure to use your non-root sudo user), and group ownership to the www-data grouping:

                      
  1. sudo chown -R sammy:www-data /var/www/html/wp-content/uploads

Next, establish the permissions that will give the spider web server write admission to this folder:

                      
  1. sudo chmod -R k+due west /var/world wide web/html/wp-content/uploads

Nosotros volition at present be able to use our plugins to create a store in object storage for the assets in the wp-content/uploads folder, and to appoint with our assets from the WordPress interface.

Installing DigitalOcean Spaces Sync

The first footstep in using DigitalOcean Spaces Sync will be to install it in our WordPress folder. We can navigate to the plugin binder within our WordPress directory:

                      
  1. cd /var/www/html/wp-content/plugins

From here, we can install DigitalOcean Spaces Sync using the wp command:

                      
  1. wp plugin install do-spaces-sync

To actuate the plugin, we tin run:

                      
  1. wp plugin activate do-spaces-sync

From hither, we tin navigate to the plugins tab on the left-manus side of our WordPress administrative dashboard:

WordPress Plugin Tab

Nosotros should see DigitalOcean Spaces Sync in our list of activated plugins:

Spaces Sync Plugin Screen

To manage the settings for DigitalOcean Spaces Sync, we tin navigate to our Settings tab, and select DigitalOcean Spaces Sync from the menu:

Settings Tab

DigitalOcean Spaces Sync will now give us options to configure our asset storage:

DO Spaces Sync Configuration

The Connection Settings field in the height one-half of the screen asks for our Spaces Admission Key and Secret. Information technology will then inquire for our Container, which will be the name of our Space, and the Endpoint.

Y'all tin make up one's mind the endpoint of your Infinite based on its URL. For case, if the URL of your Space is https://example-name.nyc3.digitaloceanspaces.com, then example-name will exist your bucket/container, and nyc3.digitaloceanspaces.com volition be your endpoint.

In the plugin's interface, the Endpoint section will be pre-filled with the default https://ams3.digitaloceanspaces.com. Y'all should modify this endpoint if your Infinite lives in another region.

Side by side, you volition be asked for File & Path Settings. In the field marked Total URL-path to files, you tin can input either a storage public domain, if your files will be stored just on your Space, or a full URL path, if you will store them on your Space and server.

For instance, if your WordPress project is located in /var/www/html, and you want to store files on both your server and Space, then you would enter:

  • http://your_server_ip/wp-content/uploads in the Full URL-path to files field
  • /var/www/html/wp-content/uploads in the Local path field

The Storage prefix and Filemask settings are prefilled, and do not demand to be modified unless yous would similar to specify certain types of files for your sync.

Nosotros will encompass the specifics of storing files on your server and Space and on your Space lonely in the following sections.

Syncing and Saving Files in Multiple Locations

DigitalOcean Spaces Sync offers the choice of saving files to your server while too syncing them to your Space. This utility can be helpful if you need to go on files on your server, but would also like backups stored elsewhere. We will go through the procedure of syncing a file to our Space while keeping it on our server. For the purposes of this example, we volition assume that we have a file called sammy10x10.png that we would like to store in our media library and on our Space.

First, navigate to the Settings tab on your WordPress administrative dashboard, and select DigitalOcean Spaces Sync from the menu of presented options.

Next, in the Connections Settings field, enter your Spaces Key and Undercover, followed by your Container and Endpoint. Remember, if the URL of your Infinite is https://example-name.nyc3.digitaloceanspaces.com, then example-name will be your Container, and nyc3.digitaloceanspaces.com will exist your Endpoint. Test your connections past clicking the Check the Connection push at the bottom of the Connection Settings field:

Check Connection Button

Now nosotros are set up to make full out the File & Path Settings.

In the Full URL-path to files field we can enter our full URL path, since nosotros are saving our file on our server and on our Space. Nosotros will use our server's IP here, but if you have a domain, you can swap out the IP address for your domain name. For more almost registering domains with DigitalOcean, see our tutorial on How To Prepare Up a Host Name with DigitalOcean. In our example, the Full URL-path to files volition be http://your_server_ip/wp-content/uploads.

Side by side, nosotros volition fill out the Local path field with the local path to the uploads directory: /var/www/html/wp-content/uploads.

Because we are working with a single file, we do not need to change the Storage prefix and Filemask sections. As your WordPress media library grows in size and variety, you tin can modify this setting to target individual file types using wildcards and extensions such as *.png in the Filemask field.

Your final File & Path Settings will wait like this:

Sync Server and Cloud

Be sure to salvage your configuration changes by clicking the Salve Changes button at the lesser of the screen.

Now we tin add together our file, sammy10x10.png, to our WordPress media library. We volition employ the wp media import control, which will import the file from our home directory to our WordPress media library. In this example, our dwelling directory will belong to sammy, only in your example this will exist your non-root sudo user. As nosotros move the file, we will apply the --path parameter to specify the location of our WordPress project:

                      
  1. wp media import --path=/var/www/html/ /home/sammy/sammy10x10.png

Looking at our WordPress interface, we should now run into our file in our Media Library. We tin navigate there by post-obit the Media Library tab on the left side of our WordPress administrative dashboard:

Media Library Tab

If nosotros navigate to our Spaces page in the DigitalOcean control console, we should also see the file in our Space.

Finally, we tin navigate to our wp-content/uploads binder, where WordPress will have created a sub-binder with the twelvemonth and calendar month. Inside this folder we should see our sammy10x10.png file.

Storing Files on Spaces

The DigitalOcean Spaces Sync plugin has an boosted selection that will allow u.s. to store files only on our Space, in instance we would like to optimize space and resources on our server. We will work with another file, sammy-heart10x10.png, and set our DigitalOcean Spaces Sync settings then that this file will be stored only on our Space.

First, allow's navigate back to the plugin'due south primary configuration page:

DO Spaces Sync Configuration

Nosotros can get out the Connection Settings information, but we will modify the File & Path Settings. First, in the Full URL-path to files, nosotros will write the storage public domain. Again, we will utilize our server IP, merely y'all tin can bandy this out for a domain if you take i: http://uploads.your_server_ip

Adjacent, we will navigate to Sync Settings, at the bottom of the page, and click the outset box, which will permit u.s. to "store files only in the cloud and delete after successful upload." Your concluding File & Path Settings will look like this:

Sync Cloud Only

Be sure to salvage your changes by clicking the Save Changes button at the bottom of the screen.

Back on the control line, nosotros will motility sammy-heart10x10.png from our user's abode directory to our Media Library using wp media import:

                      
  1. wp media import --path=/var/world wide web/html/ /dwelling/sammy/sammy-heart10x10.png

If we navigate back to our WordPress interface, we will not encounter sammy-heart10x10.png or sammy10x10.png in our Media Library. Adjacent, if we return to the command line and navigate to our wp-content/uploads directory, nosotros should see that sammy-heart10x10.png is missing from our timestamped sub-folder.

Finally, if we navigate to the Spaces page in the DigitalOcean control console, we should see both files stored in our Space.

Conclusion

We take covered ii different options you lot can use to store your WordPress media files to DigitalOcean Spaces using DigitalOcean Spaces Sync. This plugin offers boosted options for customization, which you can larn more about by reading the developer's article "Sync your WordPress media with DigitalOcean Spaces."

If you would like more general information well-nigh working with Spaces, check out our introduction to DigitalOcean Spaces and our guide to best practices for performance on Spaces.

huntleytherty.blogspot.com

Source: https://www.digitalocean.com/community/tutorials/how-to-store-wordpress-assets-on-digitalocean-spaces

0 Response to "How to Give a Wp Website User an Upload Space"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel