简体   繁体   中英

Can't install Composer on Ubuntu behind proxy

I'm trying to install Composer, in order to use Laravel, but I'm behind the company proxy. The proxy is already configured in the system, so

wget --proxy-user=<my_user_name> --proxy-password=<my_password> https://getcomposer.org/installer

works (curl doesn't!), and I get the 270kB "installer" file.

Next, I'm trying to run

php installer

as the manual says, but then I get the following error:

All settings correct for using Composer
Downloading...
Download failed: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
file_get_contents(https://getcomposer.org/composer.phar): failed to open stream: Cannot connect to HTTPS server through proxy

The error repeats 3 times, then the program quits. If I put a "sudo" before the "php", then nothing happens (it gets stuck in the "Downloading..."), as if php was waiting for something. Using

printenv | grep proxy

I get

http_proxy=http://<my_proxy_host>:<port_number>/
ftp_proxy=ftp://<my_proxy_host>:<port_number>/
all_proxy=socks://<my_proxy_host>:<port_number>/
ALL_PROXY=socks://<my_proxy_host>:<port_number>/
socks_proxy=socks://<my_proxy_host>:<port_number>/
https_proxy=https://<my_proxy_host>:<port_number>/
no_proxy=localhost,127.0.0.0/8,::1

Shouldn't it be working? I'm on a newly installed Ubuntu 14.04. I was following this tutorial , and I'm stuck on step 8 (ie I already installed Apache and PHP Version 5.5.9-1ubuntu4.9.)

Thanks in advance!

EDIT: This is not a duplicate of this question , because I cannot even INSTALL Composer! The OpenSSL in PHP is NOT the faulty 0.9.8 series (it's 1.0.1f). I've put export HTTP_PROXY_REQUEST_FULLURI=0 and export HTTPS_PROXY_REQUEST_FULLURI=0 at /etc/profile. I have the proxy variables shown above. Perhaps the problem is at the CNTLM stuff? I'll look for it.

Just install it manually.

first download the file

wget https://getcomposer.org/composer.phar

then move it under /usr/bin to have it globally.

sudo mv composer.phar /usr/bin/composer

Should do the trick on Ubuntu 14.

I got help from some experts close by:

add 3 lines to /etc/profile

export http_proxy=http://[username]:[password]@[webproxy]:[port]
export https_proxy=http://[username]:[password]@[webproxy]:[port]
export ftp_proxy=http://[username]:[password]@[webproxy]:[port]

For a similar error (apt-get update was not reaching some repositories), I edited /etc/apt/apt.conf:

Acquire::http::proxy "http://[username]:[password]@[webproxy]:[port]";
Acquire::https::proxy "https://[username]:[password]@[webproxy]:[port]";
Acquire::ftp::proxy "ftp://[username]:[password]@[webproxy]:[port]";

take care to remove the "/" after the port number (it was already there).

Now it's all working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM