IPFS Deployment and Usage Guide
1. Prerequisites
- Go 1.19 or later - IPFS is written in Go and requires a Go runtime
- Git - For cloning the repository
- Make - For building the project (optional but recommended)
- Ports 4001, 5001, and 8080 - These ports are used by IPFS for various services (libp2p, API, and gateway respectively)
2. Installation
Clone the Repository
git clone https://github.com/ipfs/ipfs.git
cd ipfs
Build from Source
make install
Verify Installation
ipfs --version
3. Configuration
Environment Variables
IPFS_PATH- Set to specify the IPFS data directory (default:~/.ipfs)IPFS_API- Configure the API address (default:/ip4/127.0.0.1/tcp/5001)IPFS_GATEWAY- Configure the gateway address (default:/ip4/127.0.0.1/tcp/8080)
Initial Configuration
# Initialize IPFS repository
ipfs init
# Configure API and Gateway addresses
ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
4. Build & Run
Development Mode
# Start IPFS daemon
ipfs daemon
# Test basic functionality
ipfs id
ipfs swarm peers
Production Mode
# Start daemon with custom configuration
ipfs daemon --enable-gc --enable-pubsub-experiment
Common Operations
# Add a file to IPFS
ipfs add <filename>
# Get a file from IPFS
ipfs get <hash>
# List all pinned objects
ipfs pin ls
5. Deployment
Docker Deployment
# Dockerfile
FROM ipfs/go-ipfs:latest
# Expose necessary ports
EXPOSE 4001 5001 8080
# Start IPFS daemon
CMD ["ipfs", "daemon", "--enable-gc"]
# Build and run
docker build -t my-ipfs .
docker run -d -p 4001:4001 -p 5001:5001 -p 8080:8080 my-ipfs
Cloud Deployment Options
AWS EC2:
- Use t3.medium or larger instance
- Open ports 4001, 5001, and 8080 in security group
- Mount EBS volume for persistent storage
DigitalOcean:
- Deploy using Marketplace 1-Click App
- Configure firewall to allow necessary ports
- Use Block Storage for data persistence
Kubernetes:
apiVersion: apps/v1
kind: Deployment
metadata:
name: ipfs-node
spec:
template:
spec:
containers:
- name: ipfs
image: ipfs/go-ipfs:latest
ports:
- containerPort: 4001
- containerPort: 5001
- containerPort: 8080
6. Troubleshooting
Common Issues
Port Already in Use
# Check what's using the port
lsof -i :5001
# Kill the process
kill -9 <PID>
Insufficient Disk Space
# Check disk usage
df -h
# Clean up old blocks
ipfs repo gc
Connection Issues
# Check if daemon is running
ps aux | grep ipfs
# Restart daemon
ipfs daemon --enable-namesys-pubsub
Bootstrap Issues
# Add default bootstrap nodes
ipfs bootstrap add /ip4/104.131.0.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ
ipfs bootstrap add /ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM
API Connection Refused
# Check API configuration
ipfs config Addresses.API
# Restart daemon with correct API address
ipfs daemon --api /ip4/0.0.0.0/tcp/5001
Performance Optimization
# Increase file descriptor limit
ulimit -n 4096
# Configure garbage collection
ipfs config Datastore.GCPeriod "1h"
# Enable experimental features
ipfs config --json Experimental.PubsubEnabled true
ipfs config --json Experimental.ShardingEnabled true