Install and Configure GitLab CE on Ubuntu 16.04
This guide walks through installing GitLab Community Edition on a fresh Ubuntu 16.04 server, configuring the firewall, and performing initial setup through the web interface.
Prerequisites
- Ubuntu 16.04 server with at least 2 CPU cores and 2 GB RAM
- A non-root user with
sudoprivileges - A domain name or static IP address pointed at the server
- UFW firewall configured (SSH allowed)
Steps
1. Install Dependencies
Update the package index and install the required packages. Select Internet Site when the Postfix installer prompts for mail configuration, then enter your server's domain name.
sudo apt-get update
sudo apt-get install -y ca-certificates curl openssh-server postfix
2. Add the GitLab Repository
Download and run the official GitLab repository setup script. Inspect the script before running if desired.
cd /tmp
curl -LO https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh
less /tmp/script.deb.sh # optional review
sudo bash /tmp/script.deb.sh
3. Install GitLab CE
sudo apt-get install -y gitlab-ce
4. Run Initial Configuration
This automated step initialises GitLab using information detected from the server.
sudo gitlab-ctl reconfigure
5. Open Firewall Ports
sudo ufw allow http
sudo ufw allow https
sudo ufw allow OpenSSH
sudo ufw status
6. First Login
Open a browser and navigate to your server's domain name or IP address:
http://your_domain_or_IP
On first visit you are prompted to set a password for the root administrator account. After setting the password, log in with username root.
Verify
sudo gitlab-ctl status
All services (unicorn, sidekiq, postgresql, redis, nginx, etc.) should show run: status.
Troubleshooting
- Reconfigure fails — check
/var/log/gitlab/reconfigure.logfor details. - Port 80 blocked — ensure
sudo ufw allow httpwas run and the cloud provider security group also allows port 80. - Low memory — GitLab requires at least 2 GB RAM; add swap if necessary before running reconfigure.
- Postfix not needed — if you use an external SMTP service, select No configuration during the Postfix prompt and configure SMTP settings in
/etc/gitlab/gitlab.rblater.