[转]Installing Jenkins on Ubuntu

On Debian-based distributions, such as Ubuntu, you can install Jenkins through apt-get.

Recent versions are available in an apt repository. Older but stable LTS versions are in this apt repository.

You need to have a JDK and JRE installed. openjdk-7-jre and openjdk-7-jdk are suggested. As of 2011-08 gcj is known to be problematic - see https://issues.jenkins-ci.org/browse/JENKINS-743.

Please make sure to back up any current Hudson or Jenkins files you may have.

Installation

wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ \
> /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins

gao@gao-VirtualBox:~$ sudo apt-get install jenkins
正在读取软件包列表... 完成
正在分析软件包的依赖关系树      
正在读取状态信息... 完成      
将会安装下列额外的软件包:
  ca-certificates-java daemon default-jre-headless icedtea-6-jre-cacao
  icedtea-6-jre-jamvm java-common openjdk-6-jre-headless openjdk-6-jre-lib
  tzdata-java
建议安装的软件包:
  default-jre equivs sun-java6-fonts ttf-dejavu-extra fonts-ipafont-gothic
  fonts-ipafont-mincho ttf-telugu-fonts ttf-oriya-fonts ttf-kannada-fonts
  ttf-bengali-fonts
下列【新】软件包将被安装:
  ca-certificates-java daemon default-jre-headless icedtea-6-jre-cacao
  icedtea-6-jre-jamvm java-common jenkins openjdk-6-jre-headless
  openjdk-6-jre-lib tzdata-java
升级了 0 个软件包,新安装了 10 个软件包,要卸载 0 个软件包,有 52 个软件包未被升级。
需要下载 105 MB 的软件包。
解压缩后会消耗掉 132 MB 的额外空间。
您希望继续执行吗?[Y/n]y

Upgrade

Once installed like this, you can update to the later version of Jenkins (when it comes out) by running the following commands:

sudo apt-get update
sudo apt-get install jenkins

(aptitude or apt-get doesn't make any difference.)

What does this package do?

  • Jenkins will be launched as a daemon up on start. See /etc/init.d/jenkins for more details.
  • The 'jenkins' user is created to run this service.
  • Log file will be placed in /var/log/jenkins/jenkins.log. Check this file if you are troubleshooting Jenkins.
  • /etc/default/jenkins will capture configuration parameters for the launch like e.g JENKINS_HOME
  • By default, Jenkins listen on port 8080. Access this port with your browser to start configuration.
If your /etc/init.d/jenkins file fails to start jenkins, on line 108 you may change su -l <username> -c <command> with sudo -u <username> <command>. This fixed init.d script for me (icarito, July 2013).

Deploying on Ubuntu in a cloud (EC2, HP Cloud, OpenStack)

The Ubuntu Jenkins maintainer also maintains the Juju charm deployment/management script for deployment in clouds. It's designed to make it easy to deploy a master with multiple slaves:

juju deploy jenkins
juju deploy -n 5 jenkins-slave
juju add-relation jenkins jenkins-slave

The default password for the 'admin' account will be auto-generated. You can set it using:

juju set jenkins password=mypassword

Always change it this way - this account is used by the charm to manage slave configuration. Then feel free to expose your jenkins master:

juju expose jenkins

Setting up an Apache Proxy for port 80 -> 8080

  • This configuration will setup Apache2 to proxy port 80 to 8080 so that you can keep Jenkins on 8080.
  • sudo aptitude install apache2
  • sudo a2enmod proxy
  • sudo a2enmod proxy_http
do not do this next command if you already have virtual hosting setup that depends on the default site. See my comment below - danapsimer
  • sudo a2dissite default
  • Create a file called jenkins.conf in /etc/apache2/sites-available
<VirtualHost *:80>
	ServerAdmin webmaster@localhost
	ServerName ci.company.com
	ServerAlias ci
	ProxyRequests Off
	<Proxy *>
		Order deny,allow
		Allow from all
	</Proxy>
	ProxyPreserveHost on
	ProxyPass / http://localhost:8080/ nocanon
	AllowEncodedSlashes NoDecode
</VirtualHost>
  • sudo a2ensite jenkins
  • sudo apache2ctl restart

Setting up an Nginx Proxy for port 80 -> 8080

This configuration will setup Nginx to proxy port 80 to 8080 so that you can keep Jenkins on 8080. Instructions originally found in a GitHub Gist from rdegges: https://gist.github.com/913102

  • Install Nginx.
    sudo aptitude -y install nginx
    
  • Remove default configuration.
    cd /etc/nginx/sites-available
    sudo rm default ../sites-enabled/default
    
  • Create new configuration for Jenkins. This example uses cat, but you can use your favorite text editor. Make sure to replace 'ci.yourcompany.com' with your domain name.
    Note: Sometimes your permissions (umask, etc) might be setup such that this won't work. Create the file somewhere else then copy it into place if you run into that problem.
    sudo cat > jenkins
    upstream app_server {
        server 127.0.0.1:8080 fail_timeout=0;
    }
    
    server {
        listen 80;
        listen [::]:80 default ipv6only=on;
        server_name ci.yourcompany.com;
    
        location / {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_redirect off;
    
            if (!-f $request_filename) {
                proxy_pass http://app_server;
                break;
            }
        }
    }
    ^D # Hit CTRL + D to finish writing the file
    
  • Link your configuration from sites-available to sites-enabled:
    sudo ln -s /etc/nginx/sites-available/jenkins /etc/nginx/sites-enabled/
    
  • Restart Nginx
    sudo service nginx restart
    

Where to go from here?

原文网址:https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: "不安装尝试Ubuntu"可以使用Ubuntu的Live CD或Live USB。这些是可启动的Ubuntu映像,可以在计算机上运行而不需要安装。您可以从Ubuntu官方网站下载Live CD或Live USB映像,然后将其刻录到CD或USB驱动器中。启动计算机时,选择从CD或USB驱动器启动,即可进入Ubuntu的Live环境。在此环境中,您可以尝试Ubuntu并测试其功能,但是您的更改不会被保存。一旦您关闭计算机,所有更改都将丢失。 ### 回答2: Ubuntu是一个流行的操作系统,通常被用作桌面和服务器环境。但是,一些用户可能不想在计算机上完全安装Ubuntu,无论是因为他们想简单地尝试它,还是因为他们使用的是不支持Ubuntu的计算机。这时,可以通过在不安装的情况下运行Ubuntu来进行尝试。 那么,如何尝试Ubuntu而不必安装?可以使用一个叫做Ubuntu Live CD / USB的功能。这是一个 Ubuntu 安装程序镜像的读写分离操作方式。简单来说,它是一个在可启动 CD / USB 驱动器中的完整 Ubuntu 操作系统。可以选择在计算机启动时从这个驱动器启动,这样就可以运行 Ubuntu 的实时版本而不必在硬盘上安装它。在 Ubuntu 实时环境中,用户可以在操作系统中浏览,熟悉它的界面、工具和应用程序。 使用 Ubuntu 实时环境时,用户可以访问 Ubuntu 系统本身、软件和文件。当然,由于是在CD或USB上运行,所以不会对计算机硬盘进行任何更改。基本上,所有操作均在随后关闭计算机后,从 CD 或 USB 驱动器中移除即可。所谓的“实时环境”意味着所有改变都不会被致久的保存在这个系统中: 所有临时数据和更改都存放在内存中,每次重新启动都会被清除。 如果正在考虑使用 Ubuntu,但是还不确定是否要完全替换您的现有操作系统,那么试用 Ubuntu 可以是不错的开端。使用 Ubuntu 实时环境,可以体验一下 Ubuntu 的系统环境,看看这个操作系统是否适合自己的需求。也可以用它进行临时任务,比如从另一个操作系统中救出数据,或者做一些需要电脑的任务但是又不想在操作系统上安装软件的工作。最重要的是,Ubuntu 实时环境使您可以无需改变计算机配置就能使用该操作系统。 ### 回答3: Ubuntu是一种基于Linux的操作系统,可以用于普通计算机或服务器等不同应用场景。使用Ubuntu的好处在于它是免费开源的,并且具有高度的安全性和稳定性。但是,在安装Ubuntu之前,您可以使用“不安装”选项来试用该操作系统。这称为试用Ubuntu而不安装。 试用Ubuntu而不安装的方法很简单。首先,您需要下载一个Ubuntu ISO映像文件,并将其烧录到USB存储器或DVD上。然后,在计算机启动时,您需要启动电脑的BIOS或UEFI设置并选择使用USB或DVD引导的选项。接下来,您会看到一个Ubuntu启动菜单,选择“试用Ubuntu”选项即可开始体验Ubuntu操作系统。 在试用Ubuntu过程中,您可以尝试使用Ubuntu的各种功能,例如:网络、文件浏览和文本编辑等,以了解该操作系统的使用方式和通用功能。请注意,试用Ubuntu是在计算机的内存中运行Ubuntu,因此所有更改都会在关机时消失。试用Ubuntu不会安装Ubuntu在硬盘上,因此它不会影响计算机上现有的数据或文件。 试用Ubuntu的优点是,它可以让您在将Ubuntu安装在计算机之前先了解操作系统的基础功能,这样您就可以确保该操作系统能够满足您的需求。此外,它也是一个检验系统兼容性和稳定性的好方法,这可以让您决定是否要批量安装Ubuntu。 总之,试用Ubuntu而不安装是一个方便而实用的方法,可以让您深入了解Ubuntu,而不会对计算机进行任何有害更改。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值