Rodrigo Rodrigo - 1 year ago 201
PHP Question

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>

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
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( 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


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 (i.e. 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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download