ubuntu下jenkins部署

jdk
安装openjdk-8-jdk:

sudo apt-get install openjdk-8-jdk

查看java版本:

java -version

编辑/etc/profile,在文件尾添加java环境变量:

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
通过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创建源列表:

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

更新,并开始Jenkins的安装过程:

apt update
apt install jenkins

启动Jenkins服务

systemctl start jenkins

修改Jenkins默认的端口
1、

sudo vim /etc/init.d/jenkins

修改 do_start 函数的 check_tcp_port 命令,端口号从 8080 换成 8082(140行):

2、Jenkins默认使用8080端口,要修改此端口,编辑/etc/default/jenkins配置文件:

HTTP_PORT=8080

改成想要的端口号
3、重启

sudo systemctl restart jenkins

修改管理员信息

cd /var/lib/jenkins/users/

为Jenkins安装并配置Apache HTTP Server
启用 proxy 和 proxy_http 模块以便将 apache 配置为 Jenkins 的前端服务器/反向代理

a2enmod proxy
a2enmod proxy_http

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

粘贴下面的虚拟主机配置。

    <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 虚拟主机。

a2ensite jenkins

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容