安装jenkins
添加jenkins密钥和仓库到系统中
~$ wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
~$ echo 'deb https://pkg.jenkins.io/debian-stable binary/' | tee -a /etc/apt/sources.list
更新安装
~$ apt-get update
~$ apt-get install jenkins
启动jenkins,发现报错了
~$ systemctl start jenkins
Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service"
and "journalctl -xe" for details.</span>
输入 systemctl status jenkins.service
输出日志,报错找不到jdk的bin文件,但是jdk是可以的
Aug 23 14:51:53 VM-0-11-ubuntu systemd[1]: Starting LSB: Start Jenkins at boot time...
Aug 23 14:51:53 VM-0-11-ubuntu jenkins[752]: ERROR: No Java executable found in current PATH: /bin:/usr/bin:/sbin:/usr/sbin
Aug 23 14:51:53 VM-0-11-ubuntu jenkins[752]: If you actually have java installed on the system make sure the executable is in the aforementioned path and that 'type -p java' returns the java executable path
Aug 23 14:51:53 VM-0-11-ubuntu systemd[1]: jenkins.service: Control process exited, code=exited status=1
Aug 23 14:51:53 VM-0-11-ubuntu systemd[1]: Failed to start LSB: Start Jenkins at boot time.
Aug 23 14:51:53 VM-0-11-ubuntu systemd[1]: jenkins.service: Unit entered failed state.
Aug 23 14:51:53 VM-0-11-ubuntu systemd[1]: jenkins.service: Failed with result 'exit-code'.
下面说下2种解决方法
1.创建一条软链接 , ln -s /usr/java/jdk1.8.0_181/bin/java/usr/bin/java
,再添加环境变量, vi ~/.bashrc
export JAVA_HOME=/usr/java/jdk1.8.0_181
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
2.如果启动还是报错检查服务器安全组是否开启端口或端口是否被占用,修改端口 vi /etc/default/jenkins
#port for HTTP connector (default 8080; disable with -1)
HTTP_PORT=8090
启动jenkins
创建Jenkins,在浏览器里面输入ip:8090,开启Jenkins 进入/var/lib/jenkins/secrets/initialAdminPassword 找到密码,选择推荐安装 使用admin选择继续或者创建用户继续
配置apache做为反向代理
前面文章已经讲了apache的安装这里就不展开讲了
在sites-available目录创建新的虚拟主机文件
~$ vim /etc/apache2/sites-available/jenkins.conf
<Virtualhost *:8090>
ServerName jenkins.hakase-labs.io
ProxyRequests Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode <Proxy http://localhost:8090/*>
Order deny,allow
Allow from all
</Proxy> ProxyPass / http://localhost:8090/ nocanon
ProxyPassReverse / http://localhost:8090/
ProxyPassReverse / http://jenkins.hakase-labs.io/
</Virtualhost>
激活配置文件并重启
~$ a2ensite jenkins
~$ systemctl restart jenkins
相关路径
访问路径:http://localhost:8090
安装路径:/var/lib/jenkins
日志路径:/var/log/jenkins
版权声明:如无特殊说明,文章均为本站原创,转载请注明出处
本文链接:http://zhangyanc.club/article/apache-jenkins/
许可协议:署名-非商业性使用 4.0 国际许可协议