linux-配置minio

MinIO 服务端核心代码是 AGPLv3 开源协议,可以免费下载、部署、商用(你服务器上跑完全免费,无授权费);企业如果需要商业技术支持、商业许可,可以向 MinIO, Inc. 购买订阅服务。

下载二进制文件:https://dl.minio.org.cn/server/minio/release/linux-amd64/minio

上传到:/usr/local/bin 目录

添加执行权限:chmod +x /usr/local/bin/minio

验证:任意目录输入下面命令测试 minio –version

存储图片的数据目录(图片存放路径,和程序分开!重要区分)。程序文件 minio 放在 /usr/local/bin;图片数据目录单独创建:

mkdir -p /data/minio/goodsimg

启动命令(直接全局调用)

MINIO_ROOT_USER=admin MINIO_ROOT_PASSWORD=Abc@123456 minio server /data/minio/goodsimg --address ":9000" --console-address ":9001"

制作 systemd 开机自启

新建服务文件 vi /etc/systemd/system/minio.service

[Unit]
Description=MinIO
Documentation=https://docs.min.io
Wants=network-online.target
After=network-online.target

[Service]
User=root
Group=root
Environment="MINIO_ROOT_USER=用户名"
Environment="MINIO_ROOT_PASSWORD=密码"
Environment="MINIO_CACHE_MAX_SIZE=256M"
Environment="MINIO_BROWSER_REDIRECT_URL=https://www.chenzhuzhen.cn/minio-console"
ExecStart=/usr/local/bin/minio server /data/minio/goodsimg --address "127.0.0.1:29247" --console-address "127.0.0.1:29248"
Restart=always
LimitNOFILE=65535

[Install]
WantedBy=multi-user.target
~

加载并启动:

systemctl daemon-reload
systemctl start minio
systemctl enable minio

查看状态

systemctl status minio

nginx配置

        # ========== 新增:MinIO 图片访问(给鸿蒙APP用) ==========
        location ^~ /minio-files/ {
            proxy_pass http://127.0.0.1:29247/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_connect_timeout 60s;
            proxy_read_timeout 120s;
            add_header Cache-Control "public, max-age=86400";
        }

        # ========== 新增:MinIO 控制台(后台管理用) ==========
        location ^~ /minio-console/ {
            proxy_pass http://127.0.0.1:29248/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_connect_timeout 60s;
            proxy_read_timeout 120s;
        }

访问地址:

访问地址:
https://www.chenzhuzhen.cn/minio-files/goodsimg/pada-skip-logo-200.jpg
上传地址:
https://www.chenzhuzhen.cn/minio-console/browser/avatar

讲桶设置为公开访问

# 1. 下载 MinIO 官方命令行工具 mc
wget https://dl.minio.org.cn/client/mc/release/linux-amd64/mc -O /usr/local/bin/mc
chmod +x /usr/local/bin/mc

# 2. 绑定本地 MinIO 服务
mc alias set local http://127.0.0.1:29247 hanxinc2 密码

# 3. 给 goodsimg 桶设置公开只读权限
mc anonymous set public local/goodsimg

Access permission for ‘local/goodsimg’ is set to ‘public’

测试:https://www.chenzhuzhen.cn/minio-files/goodsimg/pada-skip-logo-200.jpg

列出全部桶

[root@iZf8z61z784gwfxlr4cc8rZ sbin]# mc ls local
[2026-10-19 19:43:50 CST]     0B avatar/
[2026-10-19 18:23:10 CST]     0B goodsimg/