Skip to content

Instantly share code, notes, and snippets.

@zouxuoz
Last active May 6, 2023 08:52
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save zouxuoz/6079f9153456423fd28c110d2fc9b035 to your computer and use it in GitHub Desktop.
Save zouxuoz/6079f9153456423fd28c110d2fc9b035 to your computer and use it in GitHub Desktop.
Install TeamCity 9.1.7 on CentOS 7.2 x64 with Nginx

Install

Follow the steps below to install TeamCity 9.1.7 on CentOS 7.2 x64 with Nginx as the proxy for port 80.

Install Team City:

wget -c https://gist.githubusercontent.com/zouxuoz/6079f9153456423fd28c110d2fc9b035/raw/install.sh -O /tmp/teamcity-install.sh
sh /tmp/teamcity-install.sh
rm -rf /tmp/teamcity-install.sh
#!/bin/bash
# Install dependencies
yum -y install java-1.8.0-openjdk.x86_64
# Install TeamCity 9.1.7 to /srv/TeamCity
wget -c https://download.jetbrains.com/teamcity/TeamCity-9.1.7.tar.gz -O /tmp/TeamCity-9.1.7.tar.gz
tar -xvf /tmp/TeamCity-9.1.7.tar.gz -C /srv
rm -rf /tmp/TeamCity-9.1.7.tar.gz
mkdir /srv/.BuildServer
# Create user for TeamCity
useradd -m teamcity
chown -R teamcity /srv/TeamCity
chown -R teamcity /srv/.BuildServer
# Added TeamCity server and build agent to systemctl
wget https://gist.github.com/zouxuoz/6079f9153456423fd28c110d2fc9b035/raw/teamcity.service -O /usr/lib/systemd/system/teamcity.service
systemctl start teamcity
systemctl enable teamcity
wget https://gist.github.com/zouxuoz/6079f9153456423fd28c110d2fc9b035/raw/teamcity-build-agent.service -O /usr/lib/systemd/system/teamcity-build-agent.service
systemctl start teamcity-build-agent
systemctl enable teamcity-build-agent
# Install Nginx
yum -y install epel-release
yum -y install nginx
wget https://gist.github.com/zouxuoz/6079f9153456423fd28c110d2fc9b035/raw/teamcity.conf -O /etc/nginx/conf.d/teamcity.conf
systemctl start nginx
systemctl enable nginx
# Install Haveged
yum -y install haveged
systemctl start haveged
systemctl enable haveged
# Install PostgreSQL
yum -y install postgresql-server postgresql-contrib
postgresql-setup initdb
wget https://gist.github.com/zouxuoz/6079f9153456423fd28c110d2fc9b035/raw/pg_hba.conf -O /var/lib/pgsql/data/pg_hba.conf
sudo systemctl enable postgresql
sudo systemctl start postgresql
# Load JDBC driver for TeamCity
wget -P /root/.BuildServer/lib/jdbc/ https://jdbc.postgresql.org/download/postgresql-9.4.1208.jre7.jar
# Create database for TeamCity
su -c 'createdb teamcity' - postgres
su -c 'psql -c "create user teamcity with password '\''teamcity'\'';"' - postgres
su -c 'psql -c "grant all privileges on database teamcity to teamcity;"' - postgres
# PostgreSQL Client Authentication Configuration File
# ===================================================
#
# Refer to the "Client Authentication" section in the PostgreSQL
# documentation for a complete description of this file. A short
# synopsis follows.
#
# This file controls: which hosts are allowed to connect, how clients
# are authenticated, which PostgreSQL user names they can use, which
# databases they can access. Records take one of these forms:
#
# local DATABASE USER METHOD [OPTIONS]
# host DATABASE USER ADDRESS METHOD [OPTIONS]
# hostssl DATABASE USER ADDRESS METHOD [OPTIONS]
# hostnossl DATABASE USER ADDRESS METHOD [OPTIONS]
#
# (The uppercase items must be replaced by actual values.)
#
# The first field is the connection type: "local" is a Unix-domain
# socket, "host" is either a plain or SSL-encrypted TCP/IP socket,
# "hostssl" is an SSL-encrypted TCP/IP socket, and "hostnossl" is a
# plain TCP/IP socket.
#
# DATABASE can be "all", "sameuser", "samerole", "replication", a
# database name, or a comma-separated list thereof. The "all"
# keyword does not match "replication". Access to replication
# must be enabled in a separate record (see example below).
#
# USER can be "all", a user name, a group name prefixed with "+", or a
# comma-separated list thereof. In both the DATABASE and USER fields
# you can also write a file name prefixed with "@" to include names
# from a separate file.
#
# ADDRESS specifies the set of hosts the record matches. It can be a
# host name, or it is made up of an IP address and a CIDR mask that is
# an integer (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that
# specifies the number of significant bits in the mask. A host name
# that starts with a dot (.) matches a suffix of the actual host name.
# Alternatively, you can write an IP address and netmask in separate
# columns to specify the set of hosts. Instead of a CIDR-address, you
# can write "samehost" to match any of the server's own IP addresses,
# or "samenet" to match any address in any subnet that the server is
# directly connected to.
#
# METHOD can be "trust", "reject", "md5", "password", "gss", "sspi",
# "krb5", "ident", "peer", "pam", "ldap", "radius" or "cert". Note that
# "password" sends passwords in clear text; "md5" is preferred since
# it sends encrypted passwords.
#
# OPTIONS are a set of options for the authentication in the format
# NAME=VALUE. The available options depend on the different
# authentication methods -- refer to the "Client Authentication"
# section in the documentation for a list of which options are
# available for which authentication methods.
#
# Database and user names containing spaces, commas, quotes and other
# special characters must be quoted. Quoting one of the keywords
# "all", "sameuser", "samerole" or "replication" makes the name lose
# its special character, and just match a database or username with
# that name.
#
# This file is read on server startup and when the postmaster receives
# a SIGHUP signal. If you edit the file on a running system, you have
# to SIGHUP the postmaster for the changes to take effect. You can
# use "pg_ctl reload" to do that.
# Put your actual configuration here
# ----------------------------------
#
# If you want to allow non-local connections, you need to add more
# "host" records. In that case you will also need to make PostgreSQL
# listen on a non-local interface via the listen_addresses
# configuration parameter, or via the -i or -h command line switches.
# DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database superuser can access the database using some other method.
# Noninteractive access to all databases is required during automatic
# maintenance (custom daily cronjobs, replication, and similar tasks).
#
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
[Unit]
Description=Startup script for TeamCity Build Agent
After=network.target
[Service]
Type=forking
ExecStart=/srv/TeamCity/buildAgent/bin/agent.sh start
ExecStop=/srv/TeamCity/buildAgent/bin/agent.sh stop
[Install]
WantedBy=multi-user.target
map $http_upgrade $connection_upgrade {
default upgrade;
'' '';
}
server {
listen 80;
server_name ci.scrumello.com;
proxy_read_timeout 1200;
proxy_connect_timeout 240;
client_max_body_size 0;
location / {
proxy_pass http://localhost:8111/;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $server_name:$server_port;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
[Unit]
Description=Startup script for TeamCity
After=network.target
[Service]
Type=forking
ExecStart=/srv/TeamCity/bin/teamcity-server.sh start
ExecStop=/srv/TeamCity/bin/teamcity-server.sh stop
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment