我正在尝试在HTTP代理后面的Composer实例上使用Vagrant。 Composer似乎需要在之前的会话中设置'http_proxy'环境变量才能看到它。一旦看到它,就没有问题。因此,如果我在新实例上运行'vagrant up',则配置将失败。如果我立即运行'vagrant provision',它将会成功。有没有办法让作曲家第一次成功运作?我尝试使用两个单独的配置脚本,但产生了相同的结果。我已经涉足了setsid无济于事,但我对它并不是很熟悉,所以我错误地使用它。
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.provision :shell, :path => "provision.sh", :privileged => false
end
provision.sh
echo "********** Configuring for HTTP Proxy **********"
http_proxy=<insert proxy value here>
echo "HTTP Proxy = " $http_proxy
# Set proxy for apt-get
echo "Acquire::http::Proxy \"$http_proxy\";" | sudo tee -a /etc/apt/apt.conf > /dev/null
# Set proxy for wget
echo "https_proxy = $http_proxy" | sudo tee -a /etc/wgetrc > /dev/null
echo "http_proxy = $http_proxy" | sudo tee -a /etc/wgetrc > /dev/null
# Set proxy for shell
echo http_proxy="$http_proxy" | sudo tee -a /etc/environment > /dev/null
sudo apt-get -q -y update
sudo apt-get install -qq -y php5-cli php5-curl
sudo wget -q -O /usr/local/bin/composer https://getcomposer.org/download/1.0.0-alpha8/composer.phar
sudo chmod 755 /usr/local/bin/composer
wget -q -O /tmp/drush.tar.gz https://github.com/drush-ops/drush/archive/6.4.0.tar.gz
sudo mkdir -p /opt/drush
sudo chown -R vagrant: /opt/drush
tar xzf /tmp/drush.tar.gz --strip 1 -C /opt/drush
cd /opt/drush
composer install
sudo ln -s /opt/drush/drush /usr/local/bin/drush
答案 0 :(得分:0)
安装http_proxy =,需要导出http_proxy =