Configure remote storage
The Remote Storage module provides the option to store media files and schedule imports/exports in a persistent, remote storage container using a storage service, such as AWS S3 or Azure Blob Storage. By default, Magento stores media files in the same filesystem that contains the application. This is inefficient for complex, multi-server configurations, and can result in degraded performance when sharing resources. With the Remote Storage module, you can store media files in the pub/media
directory and import/export files in the var
directory of the remote object storage to take advantage of server-side image resizing.
Remote storage options
You can configure remote storage using the remote-storage
option with the setup
CLI command. The remote-storage
option uses the following syntax:
1
--remote-storage-<parameter-name>="<parameter-value>"
The parameter-name
refers to the specific remote storage parameter name. The following table lists the parameters available for configuring remote storage:
Command line Parameter | Parameter name | Description | Default value |
---|---|---|---|
remote-storage-driver |
driver | Adapter name Possible values: file: Disables remote storage and uses the local filesystem aws-s3: Use the Amazon Simple Storage Service (Amazon S3) |
none |
remote-storage-bucket |
bucket | Object storage or container name | none |
remote-storage-prefix |
prefix | Optional prefix (location inside of object storage) | empty |
remote-storage-region |
region | Region name | none |
remote-storage-key |
access key | Optional access key | empty |
remote-storage-secret |
secret key | Optional secret key | empty |
Storage adapters
The default storage location is in the local filesystem. A storage adapter enables you to connect to a storage service and store your files anywhere. Magento supports configuring the following storage services:
Enable remote storage
You can install remote storage during a new Magento installation or add it to an existing Magento instance using remote-storage
parameter name-and-value pairs with setup
CLI commands. Minimally, you must supply the storage driver
, bucket
, and region
.
The following examples enable the remote storage with an AWS S3 storage adapter in the US:
-
Install new Magento with remote storage
1
bin/magento setup:install --remote-storage-driver="aws-s3" --remote-storage-bucket="myBucket" --remote-storage-region="us-east-1"
-
Enable remote storage on existing Magento
1
bin/magento setup:config:set --remote-storage-driver="aws-s3" --remote-storage-bucket="myBucket" --remote-storage-region="us-east-1"
Migrate content
After you enable remote storage for a specific adapter, you can use the CLI to migrate existing media files to the remote storage.
1
./magento2ce/bin/magento remote-storage:sync
The sync command only migrates files in the pub/media
directory, not the import/export files in the var
directory. See Scheduled Import/Export in the Magento 2.4 User Guide.