ubuntu下jenkins部署

jdk
安裝openjdk-8-jdk:

sudo apt-get install openjdk-8-jdk

查看java版本:

java -version

編輯/etc/profile,在文件尾添加java環(huán)境變量:

sudo vim /etc/profile

# 如果使用oracle java
export JAVA_HOME="/usr/lib/jvm/java-8-oracle/jre/bin"

# 如果使用openjdk
export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin"

tomcat8
通過(guò)apt安裝 tomcat8

sudo apt-get install tomcat8 tomcat8-docs tomcat8-examples tomcat8-admin -y
修改端口
sudo vim /etc/tomcat6/server.xml

71行  修改 port="80"

sudo vim /etc/default/tomcat8 ,

46行  修改為 AUTHBIND=yes

jerkins

安裝Jenkins
添加Jenkins源:

wget -q -O - http://pkg.jenkins-ci.org/debian-stable/jenkins-ci.org.key | sudo apt-key add -

為Jenkins創(chuàng)建源列表:

sh -c 'echo deb http://pkg.jenkins-ci.org/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

更新,并開始Jenkins的安裝過(guò)程:

apt update
apt install jenkins

啟動(dòng)Jenkins服務(wù)

systemctl start jenkins

修改Jenkins默認(rèn)的端口
1、

sudo vim /etc/init.d/jenkins

修改 do_start 函數(shù)的 check_tcp_port 命令,端口號(hào)從 8080 換成 8082(140行):

2、Jenkins默認(rèn)使用8080端口,要修改此端口,編輯/etc/default/jenkins配置文件:

HTTP_PORT=8080

改成想要的端口號(hào)
3、重啟

sudo systemctl restart jenkins

修改管理員信息

cd /var/lib/jenkins/users/

為Jenkins安裝并配置Apache HTTP Server
啟用 proxy 和 proxy_http 模塊以便將 apache 配置為 Jenkins 的前端服務(wù)器/反向代理

a2enmod proxy
a2enmod proxy_http

cd /etc/apache2/sites-available/
vim jenkins.conf

粘貼下面的虛擬主機(jī)配置。

    <Virtualhost *:80>
    ServerName my.jenkins.id
    ProxyRequests Off
    ProxyPreserveHost On
    AllowEncodedSlashes NoDecode
        <Proxy http://localhost:8080/*>
            Order deny,allow
            Allow from all
        </Proxy>
    ProxyPass / http://localhost:8080/ nocanon
    ProxyPassReverse / http://localhost:8080/
    ProxyPassReverse / http://my.jenkins.id/
    </Virtualhost>

保存文件。然后用 a2ensite 命令激活 Jenkins 虛擬主機(jī)。

a2ensite jenkins

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容