Skip to content

Commit edb4f5b

Browse files
committed
docs: Add Magento 2 Remote Storage documentation
1 parent e0ac25d commit edb4f5b

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
myst:
3+
html_meta:
4+
description: Configure remote storage for Magento 2.x. Learn how to configure
5+
Magento 2 to start storing files in your bucket using a single command.
6+
title: How to Configure Remote Storage for Magento 2.x | Hypernode
7+
---
8+
9+
# How to Configure Remote Storage for Magento 2.x
10+
11+
Magento 2.x supports remote storage for media files, import/export files, and other files.
12+
This feature allows you to store files in a remote storage location, such as an Amazon S3 bucket, instead of storing them on the server itself.
13+
14+
This can be useful for many reasons, such as:
15+
- Offloading storage from your server, reducing the load on your server, and improving performance.
16+
- Allows you to make use of [horizontal scaling](../../hypernode-platform/autoscaling/how-does-horizontal-autoscaling-work), as you can easily add more servers without having to worry about syncing files between them.
17+
- Allows for effortless storage capacity scaling, as you can easily increase the storage capacity of your remote storage location.
18+
- Serving assets from a CDN, which can improve the performance of your website.
19+
20+
## Configuring the application
21+
22+
Configuring Magento 2 to start storing files in your bucket is done using a single command.
23+
If you're using a different provider than AWS S3, you need to specify the `--remote-storage-endpoint` option.
24+
25+
**AWS S3**
26+
27+
```bash
28+
bin/magento setup:config:set \
29+
--remote-storage-driver="aws-s3" \
30+
--remote-storage-bucket="my_bucket_name" \
31+
--remote-storage-region="my-aws-region" \
32+
--remote-storage-key="abcd1234" \
33+
--remote-storage-secret="abcd1234"
34+
```
35+
36+
**Other S3 compatible providers**
37+
38+
```bash
39+
bin/magento setup:config:set \
40+
--remote-storage-driver="aws-s3" \
41+
--remote-storage-bucket="my_bucket_name" \
42+
--remote-storage-region="my-aws-region" \
43+
--remote-storage-key="abcd1234" \
44+
--remote-storage-secret="abcd1234" \
45+
--remote-storage-endpoint="https://my-s3-compatible.endpoint.com"
46+
```
47+
48+
## Syncing the files
49+
50+
Instead of running (which is Magento's official way to do this):
51+
52+
```bash
53+
bin/magento remote-storage:sync
54+
```
55+
56+
One can run the following instead to really speed up the process:
57+
58+
```bash
59+
aws s3 sync pub/media/ s3://my_bucket_name/media/
60+
aws s3 sync var/import_export s3://my_bucket_name/import_export
61+
```
62+
63+
This is much faster than Magento's built-in sync, because `aws s3 sync` uploads files concurrently.
64+
65+
## The storage flag file in the bucket
66+
67+
Magento's S3 implementation creates a test file called `storage.flag`, which is basically created to test if the connection works. So this is not a magic file to mark anything ([source](https://github.com/magento/magento2/blob/6f4805f82bb7511f72935daa493d48ebda3d9039/app/code/Magento/AwsS3/Driver/AwsS3.php#L104)).
68+
69+
## Magento remote storage documentation
70+
71+
- [Configure Remote Storage](https://experienceleague.adobe.com/en/docs/commerce-operations/configuration-guide/storage/remote-storage/remote-storage)
72+
- [Configure AWS S3 bucket for remote storage](https://experienceleague.adobe.com/en/docs/commerce-operations/configuration-guide/storage/remote-storage/remote-storage-aws-s3)

0 commit comments

Comments
 (0)