⚙️ Chapter 2: Installing Gitea and Dependencies
Now that we have our EC2 instance up and running, let's install Gitea and its dependencies:
sudo apt install -y git nginx mysql-server
sudo adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/git git
Why these packages?
- git: Core requirement for any Git server
- nginx: Web server to act as a reverse proxy
- mysql-server: Database for storing Gitea data
sudo mysql_secure_installation
sudo mysql -u root -p
CREATE DATABASE gitea;
CREATE USER 'gitea'@'localhost' IDENTIFIED BY 'strong-password';
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Security Tip: Use a strong, unique password for the MySQL user. Store it securely as you'll need it during Gitea configuration.
wget -O gitea https://dl.gitea.com/gitea/1.20.0/gitea-1.20.0-linux-amd64
chmod +x gitea
sudo mv gitea /usr/local/bin/
sudo mkdir -p /var/lib/gitea/{custom,data,log}
sudo chown -R git:git /var/lib/gitea
sudo chmod -R 750 /var/lib/gitea
sudo mkdir /etc/gitea
sudo chown root:git /etc/gitea
sudo chmod 770 /etc/gitea