# IT:AD:TeamCity:HowTo:Install # * [[./|(UP)]] ## Process ## * Update your Java version to latest version *first*: * [[IT/AD/Java/HowTo/Install]] * TeamCity is a [32 bit application](https://confluence.jetbrains.com/display/TCD8/Installing+and+Configuring+the+TeamCity+Server) so install it to `c:\Program Files (x86)\TeamCity` ### Preparation ### * Get Java 32 bit up to latest version *first*: * [[IT/AD/Java/Install/]] * Get Service Accounts sorted out: * Create a UserAccount in AD * Give the account local Administrator (TODO: Explore lower rights) rights on the server (eg: `258SPIKES`) * Register the account under Local Security Policy/User Rights Assigment/Log on as a Service. ### Installation ### * Download and start the installation process. The default location it wants to install to is `c:\TeamCity` * TeamCity is a [32 bit application](https://confluence.jetbrains.com/display/TCD8/Installing+and+Configuring+the+TeamCity+Server) so if you are going to change that, consider using `c:\Program Files (x86)\TeamCity` * The port it will propose is port `80`. * But this will conflict with IIS. * So change it to `8080` * Then again, as will all config files that could get lost if the OS drive has to be reformatted and reinstalled. consider putting the config files out of C drive. **Important:** The default pattern with TC is to run the webservice under `LocalSystem` account. `LocalSystem` has two important faults: a) It's very very powerful. b) It has no local %UserProfile% directory -- which is needed in some cases (see Hg and getting through the Proxy). Therefore, open *Services* and get the TeamCity Web Service running under the account before going much further. ## Installing of a more robust Db ## The default install uses some kind of proprietary light weight Db. Not good enough for production. You have to upgrade to using MsSQL. * [Reference](http://confluence.jetbrains.net/display/TCD65/Setting+up+an+External+Database) * Create a DB ('TeamCity') * Create a User ('TeamCity') * Default Db: 'TeamCity' * Schema: dbo.Owner for TeamCity * Download the [MS JDBC Drivers](http://www.microsoft.com/download/en/details.aspx?id=21599) * Unpack it * On 258SPIKES: * `C:\Program Files\Microsoft SQL Server JDBC Driver 3.0` * Copy the sqljdbc4.jar to the .BuildServer's directory: * On 258SPIKES: * from: `C:\Program Files\Microsoft SQL Server JDBC Driver 3.0` * To: `C:\_System\TeamCity\.BuildServer\lib\jdbc\` * On XACT-WS2K8--02: * To: `E:\CI\TC\.BuildServer\lib\jdbc\` * Copy the sqljdbc_auth.dll to the System32 folder: * ON 258SPIKES: * from: `C:\Program Files\Microsoft SQL Server JDBC Driver 3.0\auth\x64\sqljdbc_auth.dll` * to: `c:\Windows\System32\` folder. * Turn off TeamCity Server (Web and Build) * Open the TCDD/config folder * On 258SPIKES: * `C:\_System\TeamCity\.BuildServer\config\` * On XACT-WS2K8--02: * `E:\CI\TC\ServerConfiguration\config\` * Copy * On 258SPIKES: * from: `database.mssql.properties.dist` * to: `database.properties` * Edit the following settings in `database.properties`: `connectionUrl=jdbc:sqlserver://localhost:1433;database=TeamCity connectionProperties.user=TeamCity connectionProperties.password=M0.......1` Or if using integrated security (comment out user/password): `connectionUrl=jdbc:sqlserver://localhost:1433;database=TeamCity;integratedSecurity=true` * Turn on TeamCity Server (Web) * If you get: `SQL exception: This driver is not configured for integrated authentication.` * TODO: Didn't find the answer. * If all goes well, will be given an error message that requires an Auth Code that can be found at the bottom of: * `C:\Program Files\TeamCity\logs\teamcity-server.log` * Will look like: [2011-12-05 10:41:06,406] INFO - jetbrains.buildServer.SERVER - Administrator login is required from web UI using *authentication token: 4454922340030578307* * Enter it in the screen * In return, will get a msg saying Db Exists, but Empty. * Accept that it creates it. * 60 secs later or so, get the Agreement again. * And have to create a new Admin user. * Turn on TeamCity Server (Build) * Done with that Step. Can move on to other issues. ## Running under IIS (using HostHeaders) ## It's all very well installing TC. But it's much better if the install can use IIS's host header mechanism to host it under `teamcity.xact-solutions.com` rather than `xact-solutions.com:8090` Steps: * First, create a Website under IIS, called `teamcity.xact-solutions.com` * This is not going to be used, obviously, but without a site, the url rewritting that you'll specify below, won't occur... * You also have to ensure that it's apppool stays running. * Install Application Request Routing (ARR) * [http://bit.ly/vF8mcU](http://bit.ly/vF8mcU) * In IIS/[ServerNode]/[Features] click Application Request Routing * Create a new Farm (Any name will do -- eg: `Team City on 8090`) * Add a server to the farm (`localhost` or `192.168.0.2`) * Click Advanced, give it `Target Port` (8090) * *TODO:* Question about SSL. Hum * Save the (single server) farm, * *important*: when saving accept that it makes a Route. * Edit the Route just created: * The Route created is capturing too much (`*` routing `*` to `localhost:8090`). * Navigate up to the INetMgr -> Server / Feature View / Url Rewrite * Double click the only rule that exists ( the one created above) * Add a new *Condition* (*tip:* hard to spot) in order to refine the `*` * Input: replace `{QUERY_STRING}` with `{HTTP_HOST}` . * Note that it is HTTP_HOST -- not HTTP_POST (easy mistake) * Pattern: target (eg: `teamcity.xact-solutions.com`) . * What we just did is refine the Route to say 'collect everything, as long as that everything has a specific host name' * Apply * Now go back to `http://localhost/8090` and update Server settings path: * From: `localhost:8090` * To: `teamcity.yourserver.com` * Note that if you run into trouble you can still get into `TeamCity` via `localhost:8090` #### Todo: #### * Not sure what to do with SSL. * TODO: Havn't investigated yet how to install two different routes to the same sever...eg (`teamcity.corp.local` as well as `teamcity.corp.com`) #### Resources: ##### * Setting up a webfarm: * JobAlb posts 1 & 2: * [http://bit.ly/tCoRFW](http://bit.ly/tCoRFW) * [http://bit.ly/sJbttm](http://bit.ly/sJbttm) * Endjin post: * [http://bit.ly/rx85YN](http://bit.ly/rx85YN) * Stack Overflow: * [http://bit.ly/w25SZz](http://bit.ly/w25SZz)