我正试图在一个Vagrant实例上使用Composer,同时使用HTTP代理。Composer似乎需要在前一个会话中设置"http_proxy"环境变量才能看到它。一旦看到它,就没有问题。因此,如果我在一个新实例上运行"流浪",则配置将失败。如果我立即执行"流浪者救助",它就会成功。有没有办法让作曲家第一次成功地工作?我尝试使用两个独立的配置脚本,但结果相同。我接触过setsid,但没有用,但我对它不是很熟悉,所以我可能用错了。
流浪文件
# -*- 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
供应.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
安装http_proxy=,需要导出http_proxy=