PHASE 2 OF 15

Installation & Initial Setup

Install TeamCity 2017.2.2 on Windows or Linux, complete the setup wizard, configure a production database, install the first build agent, and lock down the server with HTTPS

InstallWindowsLinuxMySQLPostgreSQLAgent
1

System Requirements

ComponentMinimumRecommended (production)
Java (Server)JDK 8 (64-bit)JDK 8 u152+ (64-bit)
Java (Agent)JRE 6+JDK 8 (same as build tool)
RAM (Server)4 GB8–16 GB
RAM (Agent)2 GB4–8 GB (depends on build)
CPU (Server)2 cores4+ cores
Disk (Server)5 GB50–500 GB (for artifacts)
OS (Server)Windows 2008+, LinuxLinux (CentOS/Ubuntu)
DatabaseInternal HSQL (dev only)MySQL 5.6+ / PostgreSQL 9.4+
BrowserChrome 40+, Firefox 40+Chrome latest
NEVER use HSQL in production

The built-in HSQL database is single-file and not designed for concurrent access or large datasets. It will corrupt under load and cannot be migrated easily. Use MySQL or PostgreSQL from day one — even for small teams.

2

Windows Installation

1
Download the installer

Get TeamCity-2017.2.2.exe from the JetBrains website. This is the all-in-one installer containing the server, one bundled agent, and a launcher.

2
Run the installer as Administrator

Choose installation directory (default: C:\TeamCity). Select components: Server + Default Build Agent. Choose service account (recommended: create a dedicated service account, not SYSTEM).

3
Configure port (optional)

Default HTTP port is 8111. Change in the installer or later in conf/server.xml. Ensure the port is open in Windows Firewall.

4
Start as Windows service

After install, two services are registered: TeamCity Server and TeamCity Build Agent. Start both from Services or run:

# Start server
net start TCBuildAgent
net start TeamCityServer

# Or use the launcher scripts
C:\TeamCity\bin\teamcity-server.bat start
C:\TeamCity\bin\teamcity-agent.bat start
5
Open browser

Navigate to http://localhost:8111. The first-run setup wizard appears.

SERVICE ACCOUNT

Create a dedicated Windows service account (e.g., svc-teamcity) with minimal permissions. Give it read/write access to the TeamCity installation directory and data directory. Running as SYSTEM or an admin account is a security risk.

3

Linux Installation

# 1. Ensure Java 8 is installed
java -version   # must show 1.8.x

# 2. Download TeamCity tar.gz
wget https://download.jetbrains.com/teamcity/TeamCity-2017.2.2.tar.gz

# 3. Extract to /opt
sudo tar -xzf TeamCity-2017.2.2.tar.gz -C /opt
sudo mv /opt/TeamCity /opt/teamcity

# 4. Create dedicated user (never run as root)
sudo useradd -m -d /home/teamcity -s /bin/bash teamcity
sudo chown -R teamcity:teamcity /opt/teamcity

# 5. Set data directory (optional — default is ~/.BuildServer)
echo "TEAMCITY_DATA_PATH=/var/lib/teamcity" | sudo tee /opt/teamcity/conf/teamcity-startup.properties

# 6. Start the server
sudo -u teamcity /opt/teamcity/bin/teamcity-server.sh start

# 7. Start the bundled agent
sudo -u teamcity /opt/teamcity/buildAgent/bin/agent.sh start
systemd service (recommended)
# /etc/systemd/system/teamcity.service
[Unit]
Description=TeamCity Build Server
After=network.target

[Service]
Type=forking
User=teamcity
ExecStart=/opt/teamcity/bin/teamcity-server.sh start
ExecStop=/opt/teamcity/bin/teamcity-server.sh stop
PIDFile=/opt/teamcity/logs/teamcity.pid
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable teamcity
sudo systemctl start teamcity
sudo systemctl status teamcity
GOTCHA — File descriptor limits

TeamCity opens many files simultaneously. On Linux, set ulimit -n 65536 for the teamcity user. Add to /etc/security/limits.conf:
teamcity soft nofile 65536
teamcity hard nofile 65536
Without this, you'll see "Too many open files" errors under load.

4

Initial Setup Wizard

The first time you open TeamCity in a browser (http://server:8111), the setup wizard runs. It has three steps:

1
Data Directory

Confirm or change where TeamCity stores its files. Default is ~/.BuildServer. For production, choose a dedicated volume with plenty of space for artifacts. Click Proceed.

2
Database

Select your database. See section 2.5 for database-specific setup. After entering credentials, TeamCity initialises the schema (creates ~100 tables). This takes 1–3 minutes on first run.

3
Administrator Account

Create the first super admin account. Choose a strong password — this account has full system access. You can add more admins later. Accept the license agreement and click Create Account.

After the wizard you land on the Projects page. The server is running. The bundled build agent should auto-connect within 1–2 minutes and appear under Agents → All Agents as "Unauthorized" — you must manually authorize it (see Phase 6).

5

Database Configuration

MySQL setup
-- Create database and user (MySQL 5.6+)
CREATE DATABASE teamcity CHARACTER SET utf8 COLLATE utf8_bin;
CREATE USER 'teamcity'@'localhost' IDENTIFIED BY 'StrongPass123!';
GRANT ALL PRIVILEGES ON teamcity.* TO 'teamcity'@'localhost';
FLUSH PRIVILEGES;

Download the MySQL JDBC driver (mysql-connector-java-5.1.xx.jar) and place it in:

<TeamCity Data Dir>/lib/jdbc/mysql-connector-java-5.1.xx.jar

In the setup wizard, select MySQL and enter:

  • Database host: localhost (or remote host)
  • Database name: teamcity
  • Username: teamcity
  • Password: StrongPass123!
PostgreSQL setup
-- PostgreSQL 9.4+
CREATE DATABASE teamcity ENCODING 'UTF8';
CREATE USER teamcity WITH ENCRYPTED PASSWORD 'StrongPass123!';
GRANT ALL PRIVILEGES ON DATABASE teamcity TO teamcity;

Download the PostgreSQL JDBC driver (postgresql-42.x.x.jar) and place it in <Data Dir>/lib/jdbc/.

DatabaseProsCons
Internal HSQLZero setup, good for evaluationNot for production, no migration path
MySQL 5.6+Widely available, familiarRequires utf8_bin collation, driver download
PostgreSQL 9.4+Better performance at scale, recommendedSlightly more setup
MIGRATING FROM HSQL

If you started with HSQL and want to switch: go to Administration → Server Administration → Backup, create a full backup, install the new DB driver, run the setup wizard again pointing to the new DB. Then restore using the maintainDB tool provided in bin/. This process is documented in TeamCity's official "Migrating to an External Database" guide.

6

Data Directory Structure

.BuildServer/            <-- TeamCity Data Directory root
├── config/              <-- Project + build config XML files
│   ├── projects/
│   │   └── _Root/       <-- Root project settings
│   └── database.properties
├── system/
│   ├── artifacts/       <-- Published build artifacts
│   │   └── ProjectName/
│   │       └── BuildConfigName/
│   ├── caches/          <-- VCS fetch caches, checkout caches
│   └── buildserver.db   <-- HSQL data file (if using HSQL)
├── plugins/             <-- Installed .zip plugins
├── lib/
│   └── jdbc/            <-- Database driver JAR goes here
└── logs/                <-- teamcity-server.log, catalina.out
GOTCHA — Artifact disk growth

system/artifacts/ grows without bound unless you configure clean-up policies (Phase 15). For a moderately active team, this directory can consume 50–500 GB within months. Mount it on a separate volume and monitor disk usage from day one.

7

Installing the First Build Agent

The bundled agent is installed alongside the server but must be authorized before it can run builds. For a remote agent (separate machine):

# On the agent machine — download agent installer from server
wget http://YOUR_TC_SERVER:8111/update/buildAgent.zip
unzip buildAgent.zip -d /opt/buildagent

# Configure the agent to connect to the server
cat > /opt/buildagent/conf/buildAgent.properties << 'EOF'
serverUrl=http://YOUR_TC_SERVER:8111
name=Agent-Linux-01
workDir=../work
tempDir=../temp
EOF

# Start the agent
/opt/buildagent/bin/agent.sh start
Authorizing the agent

After the agent starts, it appears in Agents → Unauthorized Agents in the TeamCity UI. Click Authorize. The agent is now ready to accept builds.

AGENT DOWNLOAD URL

TeamCity serves the agent installer directly from the server at http://SERVER:8111/update/buildAgent.zip. This ensures the agent version always matches the server version. Never download the agent from a different source.

8

Verifying the Installation

1
Server health page

Navigate to Administration → Server Administration → Diagnostics. Check for any red warnings about memory, database, or disk space.

2
Agent connected

Agents → All Agents — at least one agent should show Connected, Authorized, Idle.

3
Create a test build

Create a project → add a Command Line build step with echo "Hello TeamCity" → run it. A green build confirms everything works end-to-end.

4
Check logs

<Data Dir>/logs/teamcity-server.log — no ERROR or FATAL lines. Agent log: <Agent Dir>/logs/teamcity-agent.log.

9

Post-Install Configuration

HTTPS with a reverse proxy (nginx)
# /etc/nginx/sites-available/teamcity
server {
    listen 443 ssl;
    server_name ci.yourcompany.com;

    ssl_certificate     /etc/ssl/certs/yourcompany.crt;
    ssl_certificate_key /etc/ssl/private/yourcompany.key;

    location / {
        proxy_pass         http://localhost:8111;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection "upgrade";
        proxy_set_header   Host $host;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
        proxy_read_timeout 600;
        proxy_connect_timeout 600;
        proxy_send_timeout 600;
    }
}

# Redirect HTTP to HTTPS
server {
    listen 80;
    server_name ci.yourcompany.com;
    return 301 https://$host$request_uri;
}

Tell TeamCity about the public HTTPS URL: Administration → Server Administration → Server URL → set to https://ci.yourcompany.com. This ensures links in emails and commit statuses use the correct URL.

Email server (for notifications)

Go to Administration → Email Notifier. Enter your SMTP server details. Click Test connection before saving. Without this, build failure emails won't work.

Server memory tuning
# <TeamCity>/bin/teamcity-server.sh — set JVM heap
export TEAMCITY_SERVER_MEM_OPTS="-Xms1g -Xmx4g -XX:MaxPermSize=270m"

# For Java 8, also add:
# -XX:+UseG1GC -XX:MaxGCPauseMillis=200
GOTCHA — Default 750 MB heap is too small

The default TeamCity heap is only 750 MB. For any team with more than a handful of builds per day, you'll hit OutOfMemoryError. Set -Xmx4g minimum for production. Restart the server after changing this.

Up Next — Phase 3: Projects & Project Hierarchy

Learn how to structure your TeamCity server with projects and subprojects, create projects from a VCS URL, and configure project-level settings shared by all builds.

Continue to Phase 3 → Back to Hub