shell - 在 Vagrant 中安装 Jenkins 后,无法从浏览器连接

标签 shell ubuntu jenkins continuous-integration vagrant

我正尝试在 Vagrant 上为我的开发环境安装 Jenkins。

我选择 Ubuntu http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-vagrant-amd64-disk1.box对于我的盒子。这是我用来配置我的盒子的 shell 。一切顺利,但是当我尝试从端口 80 甚至 :8080 访问该框时,它只是没有响应。浏览一直在旋转。不确定我在这里做错了什么。

这是我的脚本。


sudo apt-get update

echo "APT::Cache-Limit "100000000";" >> /etc/apt/apt.conf.d/70debconf

wget -q -O - http://pkg.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 -y --force-yes install jenkins

sudo apt-get -y --force-yes install apache2
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod vhost_alias
sudo a2dissite default

echo '
        ServerAdmin webmaster@localhost
        ServerName ci.company.com
        ServerAlias ci
        ProxyRequests Off
        
                Order deny,allow
                Allow from all
        
        ProxyPreserveHost on
        ProxyPass / http://localhost:8080/
' >> /etc/apache2/sites-available/jenkins

sudo a2ensite jenkins
sudo sh -c 'echo "ServerName localhost" >> /etc/apache2/conf.d/name' && sudo service apache2 restart
sudo apache2ctl restart

Also I vagrant ssh and run

curl 'http://localhost:8080'

它返回了 Jenkins 页面,因此我认为 Jenkins 已启动并正常运行。我只是无法从外面访问它。

这是我的 Vagrantfile


Vagrant.configure("2") do |config|
  config.vm.provision :shell, :path => "install-jenkins.sh"
  config.vm.provider "virtualbox" do |v|
    v.customize ["modifyvm", :id, "--memory", "2024"]
  end

  # Every Vagrant virtual environment requires a box to build off of.
  config.vm.box = "ubuntu64"

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  config.vm.network :forwarded_port, guest: 80, host: 8080
end

最佳答案

我通过像这样向 Vagrant box 提供 IP 来完成这项工作:

config.vm.network :hostonly, "33.33.33.10"

关于shell - 在 Vagrant 中安装 Jenkins 后,无法从浏览器连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15943674/

相关文章:

php - EC2 用户数据卡在 "Checking init scripts..."ubuntu php

continuous-integration - 在 Jenkins 中设置来自主作业的下游作业的构建号

linux - bash:运行一个命令 n 分钟,然后 SIGHUP 它

linux - 如何在 Linux 终端中删除 CRLF 字符(回车换行符)?

apache - apache2、apache2-threaded-dev 和 apache-prefork-dev 之间的区别

php - 如何在 ubuntu 中安装特定版本的 HHVM

linux - find -name "*.xyz"-o -name "*.abc"-exec 对所有找到的文件执行,而不仅仅是指定的最后一个后缀

regex - 如何从 Unix shell 变量中提取与模式匹配的子字符串

ubuntu - Jenkinsauthorized_keys错误

Jenkins 的 PHP 构建失败,出现 'Cannot run program "phploc"'