溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

TeamCity : 安裝 Server

發(fā)布時間:2020-10-12 12:47:23 來源:網(wǎng)絡(luò) 閱讀:396 作者:jjjyyy66 欄目:數(shù)據(jù)庫

        

    本文介紹在 Ubuntu Server 14.04 中安裝 TeamCity Server 10.0.1。Ubuntu Server 上已經(jīng)創(chuàng)建了用戶  tcuser。TeamCity 的安裝包為 TeamCity-10.0.1.tar.gz,使用 Postgresql 9.4 代替 TeamCity 自帶的數(shù)據(jù)庫。

    安裝Postgresql 數(shù)據(jù)庫

    請參考筆者之前的博文《Ubuntu14.04安裝postgresql9.4》安裝 Postgresql 9.4,并參照文中的描述創(chuàng)建數(shù)據(jù)庫 tcdb 和角色 dbuser。注意,請為 tcuser 設(shè)置密碼,這樣就為后面配置 TeamCity 做好了準(zhǔn)備。

    安裝JDK

    請參考筆者之前的博文《Ubuntu14.04安裝JDK》安裝 JDK。

    解壓縮 TeamCity Server 安裝包

    使用 tcuser 登錄 Ubuntu Server 使用下面命令把文解壓的家目錄下:

    $ tar -xf TeamCity-10.0.1.tar.gz -C ~/

    設(shè)置 Postgresql JDBC 驅(qū)動

    在 tcuer 用戶家目錄下創(chuàng)建 .BuildServer/lib/jdbc 目錄。
到 postgresql 的官網(wǎng)下載 9.4 的 jdbc 驅(qū)動 postgresql-9.4-*.jar (請根據(jù)您的JDK版本下載對應(yīng)的驅(qū)動版本)。
把下載到的 postgresql 驅(qū)動放在目錄 ~/.BuildServer/lib/jdbc 下。

    初始化TeamCity Server

    到 /home/tcuser/TeamCity/bin 目錄,執(zhí)行下面命令:

    $ ./teamcity-server.sh start

    在瀏覽器中通過IP訪問 xxx.xxx.xxx.xxx:8111/,開始初始化 TeamCity Server。

    

    直接下一步,

    

    選擇 PostgreSQL 數(shù)據(jù)庫,

    

    設(shè)置數(shù)據(jù)庫和數(shù)據(jù)庫用戶。然后同意許可協(xié)議就可以創(chuàng)建管理員賬戶了:

    

    創(chuàng)建完管理員賬戶就算是完成了 TeamCity Server 的初始化過程。登錄后是這個樣子:

    

    這可不算完喲,后面還有不少任務(wù)呢!

    配置teamcity service 開機(jī)啟動

    設(shè)置 linux 開機(jī)自動啟動 teamcity service。
創(chuàng)建文件 /etc/init.d/tcserver,添加下面的內(nèi)容,注意 jdk 的路徑要更新為實際的路徑:

    TeamCity : 安裝 Server

    #!/bin/sh# /etc/init.d/teamcity -  startup script for teamcity
export JAVA_HOME=/usr/lib/jdk1.8.0_91
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
export TEAMCITY_DATA_PATH="/home/tcuser/.BuildServer"export TEAMCITY_SERVER_OPTS=-Djava.awt.headless=true# Configure TeamCity for use on a headless OS.case $1 instart)
  start-stop-daemon --start -c tcuser --exec /home/tcuser/TeamCity/bin/teamcity-server.sh start
;;
stop)
  start-stop-daemon --start -c tcuser --exec /home/tcuser/TeamCity/bin/teamcity-server.sh stop
;;esacexit 0

    TeamCity : 安裝 Server

    然后執(zhí)行下面的命令設(shè)置開機(jī)啟動服務(wù):

    $ sudo chmod 755 tcserver
$ sudo update-rc.d tcserver defaults

    配置80端口

    下面使用 nginx 讓用戶可以通過80端口來訪問 TeamCity Server。
install nginx:

    $ sudo apt-get install nginx
$ sudo touch /etc/nginx/sites-available/teamcity
$ sudo vim /etc/nginx/sites-available/teamcity

    把下面的內(nèi)容添加到 teamcity 文件中:

    TeamCity : 安裝 Server

    map $http_upgrade $connection_upgrade {
    default upgrade;    ''   '';
}

server {
    listen       80;
    server_name  localhost;
    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;
    }
}

    TeamCity : 安裝 Server

    創(chuàng)建鏈接文件并移除默認(rèn)的網(wǎng)站配置:

    $ sudo ln -s /etc/nginx/sites-available/teamcity /etc/nginx/sites-enabled/teamcity
$ sudo rm /etc/nginx/sites-enabled/default

    重新加載 nginx的配置:

    $ sudo /etc/init.d/nginx reload

    好了,現(xiàn)在就可以通過 TeamCity Server 的 IP 地址來訪問網(wǎng)站了!

    通過名稱訪問

    現(xiàn)在我們只能通過在瀏覽器中輸入IP地址的方式訪問 TeamCity server,這太不方便了。從根本上解決這個問題的方式是讓 DNS 解析域名。作為 demo,我們可以設(shè)置一下本機(jī)的 hosts文件,簡單又便捷:
使用管理員權(quán)限打開文件 C:\Windows\System32\drivers\etc\hosts,在文件尾部添加一行,內(nèi)容如下:
xxx.xxx.xxx.xxx    tcserver
保存,然后在瀏覽器中輸入 tcserver/ 試試,已經(jīng)可以通過 tcserver 來訪問 TeamCity Server 網(wǎng)站了!

    作者:sparkdev

    

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI