By default, your application's filesystems configuration file contains a disk configuration for the s3 disk. In addition to using this disk to interact with Amazon S3, you may use it to interact with any S3-compatible file storage service , and MiniIO is the greate choice here.
Let's say, the .env file has this block
FILESYSTEM_DISK=s3
AWS_ACCESS_KEY_ID=access_key
AWS_SECRET_ACCESS_KEY=secrete_key
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=xxxxxxx
AWS_ENDPOINT=xxxxxxx
There are two ways to setup MiniIO locally
- Set up directly in the localhost Easy step with 1 command
brew install minio/stable/minio
Then launch the MinIO Server by running the following command. If desired, you can replace ~/data with another localtion of Storage to read, write and delete access for the MinIO instance
export MINIO_CONFIG_ENV_FILE=/etc/default/minio
minio server ~/data --address :9001 ### API (S3 compatible)
minio server ~/data --console-address :9002 ### Web UI (User Interface)
After you run these above commands, it will print out
Status: 1 Online, 0 Offline.
API: http://192.168.2.100:9001 http://127.0.0.1:9001
RootUser: myminioadmin
RootPass: minio-secret-key-change-me
Console: http://192.168.2.100:9002 http://127.0.0.1:9002
RootUser: myminioadmin
RootPass: minio-secret-key-change-me
Command-line: https://min.io/docs/minio/linux/reference/minio-mc.html
$ mc alias set myminio http://10.0.2.100:9001 myminioadmin minio-secret-key-change-me
Documentation: https://min.io/docs/minio/linux/index.html
Now, you have access_key
and secrete_key
which is RootUser
, and RootPass
. And let's paste to the .env file
FILESYSTEM_DISK=s3
AWS_ACCESS_KEY_ID=myminioadmin
AWS_SECRET_ACCESS_KEY=minio-secret-key-change-me
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=<name_bucket_desire>
AWS_ENDPOINT=http://127.0.0.1:9001
You can connect and interact with MinIO from Laravel Application
Open browser with address: http://127.0.0.1:9002, bummmm MinIO UI appears excellently
- Setup by using Docker the docker-compose.yml will look like
version: '3.8'
services:
minio:
image: quay.io/minio/minio:latest # Or your preferred MinIO image
container_name: minio
ports:
- "9001:9001" # Expose the MinIO server port
- "9002:9002" # Expose the MinIO console port
environment:
MINIO_ACCESS_KEY: minioadmin # Replace with your desired username
MINIO_SECRET_KEY: minioadmin # Replace with your desired password
MINIO_DEFAULT_BUCKETS: "my-test-bucket" # Optional: create a default bucket
volumes:
- ./data:/data # Persistent storage for MinIO data
command: server /data --address ":9001" --console-address ":9002" # Start MinIO server with console on port 9001
restart: unless-stopped # Restart policy for the container
And all the rest is like the option#1 to connect and interact with MinIO
Reference:
Top comments (0)