Install MinIO for Object Storage on Ubuntu 22.04

By Anurag Singh

Updated on Jul 13, 2024

Install MinIO for Object Storage on Ubuntu 22.04

In this tutorial, we'll explain how to install MinIO for Object Storage on Ubuntu 22.04 with reserved proxy Nginx and secure with SSL Let's Encrypt . It's an open-source object storage server compatible with the Amazon S3 cloud storage service.

It is designed for high performance and can be used to store unstructured data such as photos, videos, log files, backups, and container images. This tutorial provides step-by-step instructions for installing and setting up MinIO on an Ubuntu system.

Prerequisites

Before you begin, ensure you have:

  • An Ubuntu 22.04 installed dedicated server or KVM VPS.
  • Sudo privileges.
  • A stable internet connection.
  • A domain name pointed to your server's IP address.

Step 1: Update Your System

First, update your package repository to ensure all packages are up to date.

sudo apt update
sudo apt upgrade -y

Step 2: Download and Install MinIO

Download the latest stable MinIO server binary from the official MinIO website.

wget https://dl.min.io/server/minio/release/linux-amd64/minio

Make the downloaded binary executable.

chmod +x minio

Move the executable to /usr/local/bin so it can be accessed system-wide.

sudo mv minio /usr/local/bin/

Step 3: Configure MinIO

Now, let proceed with the configuration of MinIO.

First, create a MinIO user.

For security reasons, it is a good practice to run MinIO as a non-root user.

sudo useradd -r minio-user -s /sbin/nologin

Next, create directories for MinIO data and configuration.

Create directories where MinIO will store its data and configuration files.

sudo mkdir /usr/local/share/minio
sudo mkdir /etc/minio

Change the ownership of these directories to the MinIO user.

sudo chown -R minio-user:minio-user /usr/local/share/minio
sudo chown -R minio-user:minio-user /etc/minio

Next, set up environment variables.

Create a file to store MinIO environment variables.

sudo nano /etc/default/minio

Add the following content to the file, replacing YOUR_ACCESS_KEY and YOUR_SECRET_KEY with your desired credentials:

MINIO_VOLUMES="/usr/local/share/minio/"
MINIO_OPTS="--address :9000"
MINIO_ACCESS_KEY="YOUR_ACCESS_KEY"
MINIO_SECRET_KEY="YOUR_SECRET_KEY"

Save and close the file.

Finally, create a Systemd service file for MinIO.

Create a systemd service file to manage the MinIO service.

sudo nano /etc/systemd/system/minio.service

Add the following content to the file:

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

[Service]
User=minio-user
Group=minio-user
EnvironmentFile=/etc/default/minio
ExecStart=/usr/local/bin/minio server $MINIO_OPTS $MINIO_VOLUMES
Restart=always
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

Save and close the file.

Reload the systemd manager configuration to apply the changes.

sudo systemctl daemon-reload

Start the MinIO service.

sudo systemctl start minio

Enable the MinIO service to start on boot.

sudo systemctl enable minio

Step 4: Configure Firewall

If you have a firewall enabled, you need to allow traffic on MinIO's default port (9000).

sudo ufw allow 9000

Note: The default port may be different for you.

Before proceeding further, first, navigate to your browser and access http://[your_server_ip]:9000, check it will redirect to another port. Copy or remember that port, we need to add it in Nginx configuration file. Also add that port in firewall too. For this tutorial, we got 37507 port. 

Step 5: Install Nginx

If Nginx is not already installed on your server, install it using the following commands:

sudo apt install nginx -y

Configure Nginx

Create a new Nginx server block for your domain. Replace your_domain with your actual domain name:

sudo nano /etc/nginx/sites-available/your_domain

Add the following configuration to the file:

server {
    listen 80;
    server_name your_domain www.your_domain;

    location / {
        proxy_pass http://127.0.0.1:37507;  # Adjust this line to match your MinIO server configuration if needed
        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;
    }
}

Save and exit the file.

Enable the server block by creating a symbolic link to the sites-enabled directory:

sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/

Test the Nginx configuration and reload it:

sudo nginx -t
sudo systemctl reload nginx

Step 6: Secure with SSL using Certbot

Install Certbot and the Nginx plugin for Certbot:

sudo apt install certbot python3-certbot-nginx -y

Obtain an SSL Certificate

Use Certbot to obtain an SSL certificate for your domain. Certbot will automatically configure Nginx to use the new certificate:

sudo certbot --nginx -d your_domain -d www.your_domain

Follow the prompts to complete the setup. Certbot will automatically update your Nginx configuration to use the obtained certificate.

Verify the Certificate Renewal

Certbot automatically installs a cron job to renew the certificate before it expires. You can test the renewal process with:

sudo certbot renew --dry-run

Step 7: Access MinIO Web Interface

Open a web browser and navigate to https://[domain_name]. Use the credentials you set in the /etc/default/minio file to log in.

Install MinIO for Object Storage on Ubuntu

Conclusion

You have successfully installed and configured MinIO on your Ubuntu server. MinIO is now ready to be used as a high-performance, S3-compatible object storage server. You can start uploading and managing your data through the web interface or using the MinIO client (mc).

Additional Resources

MinIO Documentation
MinIO GitHub Repository
Feel free to explore more advanced configurations and integrations with other tools as needed for your specific use case.