Centos6.6 安装jenkins及配置Nginx

安装最新版Jenkins

添加jenkins yum源:

安装稳定版Jenkins

There is also a LTS YUM repository for the LTS Release Line

安装Java

Jenkins requires Java in order to run, yet certain distros don't include this by default. To install the Open Java Development Kit (OpenJDK) run the following:

sudo yum install java

Note: 如果Java/Jdk安装到其他目录,使用软连接命令ln -s XXXX/bin/java /usr/bin/java;或者编辑:vi /etc/init.d/jenkins中”candidates=“选项


目录说明


  • 日志: /var/log/jenkins
  • 配置文件:/etc/sysconfig/jenkins
  • 服务配置文件:/etc/init.d/jenkins
  • Jenkins源文件地址:/var/cache/jenkins/war/
  • Jenkins War包地址:/usr/lib/jenkins/jenkins.war

Nginx配置Jenkins


配置文件如下(https://gist.github.com/coffeencoke/3885343):


     
     
server {
listen 8090; # Listen on port 80 for IPv4 requests
 
server_name build.yourdomain.com;
 
access_log /var/log/nginx/jenkins_access.log;
error_log /var/log/nginx/jenkins_error.log;
 
location ~ ^/static/[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]\/(.*)$ {
#rewrite all static files into requests to the root
#E.g /static/12345678/css/something.css will become /css/something.css
rewrite "^/static/[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]\/(.*)" /$1 last;
}
 
location /userContent {
#have nginx handle all the static requests to the userContent folder files
#note : This is the $JENKINS_HOME dir
root /var/lib/jenkins/;
if (!-f $request_filename){
#this file does not exist, might be a directory or a /**view** url
rewrite (.*) /$1 last;
break;
}
sendfile on;
}
 
location @jenkins {
sendfile off;
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;
 
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_max_temp_file_size 0;
 
#this is the maximum upload size
client_max_body_size 10m;
client_body_buffer_size 128k;
 
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
 
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
 
location / {
root /var/cache/jenkins/war/;
try_files $uri @jenkins;
}
}

 
 
Note:  启动Nginx之后,不要忘了启动Jenkins!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值