M
M
mr_blond972015-07-05 03:24:30
linux
mr_blond97, 2015-07-05 03:24:30

Why does curl work as root and not from php?

When you try to access the address in the browser, the page opens.
If I write https:// address in the curl console under root, then everything works,
but when I do it from php, it doesn’t work. Curl says Curl error: Couldn't resolve host " https://address ". Those. it cannot find the domain in DNS. If you explicitly add this address to /etc/hosts, the error disappears. What could be the problem, Apache has no rights? network settings?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
sasha, 2015-07-05
@madmages

99.99999999% that there are not enough rights

F
Fedcomp, 2015-07-05
@Fedcomp

Check that the console client speaks from under the Apache user.

HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1`
sudo -u $HTTPDUSER curl -vvv http://example.com

S
ShamblerR, 2015-07-06
@ShamblerR

Oh my God
, did you install it for php at all?
sudo apt-get install php5-curl

V
Vlad Zhivotnev, 2015-07-06
@inkvizitor68sl

> Curl error: Couldn't resolve host " https://address ".
The request was formed incorrectly.
https is a scheme, but for some reason it got into your domain name.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question