They will be used in the installation process. Change them if you need to.
TC_VERSION="2026.1"
LINUX_USERNAME="$USER" # TeamCity service will start on behalf of the current user
LINUX_USERGROUP=$LINUX_USERNAME
TEAMCITY_HOME="/opt/teamcity" # directory where you want to install TeamCity server
AGENT_HOME="$TEAMCITY_HOME/buildAgent" # [optional] agent directory (if you want to run a build agent on the same machine - do NOT do this in production)sudo yum install java-21-amazon-corretto-headlessFor Ubuntu, refer to official Amazon docs.
Verify installation.
java --versionDownload the distribution.
wget https://download.jetbrains.com/teamcity/TeamCity-$TC_VERSION.tar.gzCreate the install dir and set permissions.
sudo mkdir $TEAMCITY_HOME
sudo chown -R $LINUX_USERNAME:$LINUX_USERGROUP $TEAMCITY_HOMEExtract the files and put them into the install dir.
tar -zxf TeamCity-$TC_VERSION.tar.gz
mv TeamCity/* $TEAMCITY_HOMEClean up temp files.
rm TeamCity-$TC_VERSION.tar.gz
rm -r TeamCitySave the variabile globally and force the shell to load it without reboot.
echo "TEAMCITY_SERVER_MEM_OPTS=-Xmx4g" | sudo tee -a /etc/environment >/dev/null
source /etc/environmentCreate a systemd service configuration file.
sudo tee /etc/systemd/system/teamcity-server.service > /dev/null <<EOF
[Unit]
Description=TeamCity Server
After=network.target
[Service]
Type=forking
PIDFile=$TEAMCITY_HOME/logs/teamcity.pid
ExecStart=$TEAMCITY_HOME/bin/teamcity-server.sh start
ExecStop=$TEAMCITY_HOME/bin/teamcity-server.sh stop
User=$LINUX_USERNAME
Group=$LINUX_USERGROUP
EnvironmentFile=/etc/environment
[Install]
WantedBy=multi-user.target
EOFEnable service startup on reboot and start the service.
sudo systemctl enable teamcity-server.service
sudo systemctl start teamcity-server.serviceWarning
This is for PoC only! Do NOT run the agent on the same machine as the server in production!
Create a systemd service configuration file.
sudo tee /etc/systemd/system/teamcity-agent.service > /dev/null <<EOF
[Unit]
Description=TeamCity Build Agent
After=network.target
[Service]
Type=oneshot
User=$LINUX_USERNAME
Group=$LINUX_USERGROUP
ExecStart=$AGENT_HOME/bin/agent.sh start
ExecStop=-$AGENT_HOME/bin/agent.sh stop
# Support agent upgrade as the main process starts a child and exits then
RemainAfterExit=yes
# Support agent upgrade as the main process gets SIGTERM during upgrade and that maps to exit code 143
SuccessExitStatus=0 143
[Install]
WantedBy=default.target
EOFEnable service startup on reboot and start the service.
sudo systemctl enable teamcity-agent.service
sudo systemctl start teamcity-agent.service