PHP safe_mode problem using curl [duplicate]

2019-06-06 05:02发布

问题:

This question already has an answer here:

  • something went wrong with CURLOPT_FOLLOWLOCATION? 5 answers

I want to use cURL on my server, but it gives me the following error

Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot
be activated when in safe_mode or an open_basedir is set in
/www/htdocs/w009663c/download/webapp/browser/pproxy.php on line 180

Warning: Cannot modify header information - headers already sent 
by (output started at /www/htdocs/w009663c/download/webapp/browser/
pproxy.php:180) 
in /www/htdocs/w009663c/download/webapp/browser/pproxy.php on line 242
{"status":{"http_code":301},"contents":""}

I requested the server admin to switch of safe_mode but he says that it is already switched off.

What else could cause this problem?

回答1:

CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set

I'd assume open_basedir is set then and since that seems to be a shared server i'd assume they are not going to turn that off

Put

<?php 
phpinfo();

into a file and look at the output to see the configuration settings.

Maybe a workaround

Have a look at this comment of the curl-setopt manual:

http://php.net/manual/ro/function.curl-setopt.php#102121

Maybe that workaround works for you



回答2:

Maybe the second part of the error message: or an open_basedir is set

Let me guess, you are using Plesk as control panel? Its Plesk that usually puts open_basedir setting...



回答3:

Have you checked both open_basedir as well as safe_mode with ini_get()? They may actually not be turned off or you may have an open_basedir set.

If you're using plesk, this link may help: http://www.linuxweblog.com/plesk-vhost.conf



回答4:

There are a few workarounds listed in the manual pages for curl: http://www.php.net/manual/en/function.curl-setopt.php#102121

The other workaround would be to use PEAR Http_Request or Zend_Http.



标签: php safe-mode