Deploying Your Own Git Server with Gitea

What You’ll Need A server or virtual machine running Linux (Ubuntu 20.04+ recommended). At least 2 GB RAM, 2 CPUs, and 10 GB of storage. Docker installed (or a standalone binary setup). SSH access to the server. Step 1: Install Docker (If Not Installed) Update the system sudo apt update && sudo apt upgrade -y Install Docker sudo apt install docker.io -y sudo systemctl enable --now docker Verify the installation docker --version Step 2: Deploy Gitea with Docker Create a directory for Gitea data mkdir -p ~/gitea/{data,config} Run the Gitea container docker run -d --name gitea \ -p 3000:3000 -p 2222:22 \ -v ~/gitea/data:/data \ --restart always \ gitea/gitea:latest Check if the container is running docker ps Step 3: Configure Gitea Access the web interface Open your browser and go to: http://<your_server_ip>:3000 Set up the database Choose SQLite for a simple setup (or configure MySQL/PostgreSQL). Configure the repository root directory: /data/gitea-repositories. Set the SSH port to 2222 (or leave default if using another port). Create an Admin Account Enter the first admin user details. Complete the setup and restart Gitea. Step 4: Create a Repository Log in to Gitea Navigate to Repositories > New Repository. Enter a repository name and select visibility. Click Create Repository. Push Code to Your New Repo git clone ssh://git@<your_server_ip>:2222/user/repository.git cd repository echo "# My Self-Hosted Git Repo" > README.md git add . git commit -m "Initial commit" git push origin main Step 5: Enable HTTPS with a Reverse Proxy (Optional) To secure Gitea with HTTPS, you can use Nginx as a reverse proxy. ...

2025-02-27 · 3 min