allow_url_fopen局部变量

时间:2016-03-03 03:01:37

标签: php phpmyadmin recaptcha

我通过添加两个变量

在phpMyAdmin中添加了recaptcha
  

$ cfg [' CaptchaLoginPublicKey'] ='网站密钥';

     

$ cfg [' CaptchaLoginPrivateKey'] ='密钥';

但我的错误如下。

Warning in ./libraries/plugins/auth/recaptcha/ReCaptcha/RequestMethod/Post.php#68
 file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0

Backtrace

./libraries/plugins/auth/recaptcha/ReCaptcha/RequestMethod/Post.php#68: file_get_contents(
string 'https://www.google.com/recaptcha/api/siteverify',
boolean false,
resource,
)
./libraries/plugins/auth/recaptcha/ReCaptcha/ReCaptcha.php#94: ReCaptcha\RequestMethod\Post->submit(object)
./libraries/plugins/auth/AuthenticationCookie.class.php#366: ReCaptcha\ReCaptcha->verify(
string '03AHJ_VuvVnV4jlI2mNDNogB6eajU4jE--F7ve8zMdP0Xf636gaBeNE_dK9-',
string '10.0.5.1',
)
./libraries/common.inc.php#896: AuthenticationCookie->authCheck()
./index.php#12: require_once(./libraries/common.inc.php)

Warning in ./libraries/plugins/auth/recaptcha/ReCaptcha/RequestMethod/Post.php#68
file_get_contents(https://www.google.com/recaptcha/api/siteverify): failed to open stream: no suitable wrapper could be found

Backtrace

./libraries/plugins/auth/recaptcha/ReCaptcha/RequestMethod/Post.php#68: file_get_contents(
string 'https://www.google.com/recaptcha/api/siteverify',
boolean false,
resource,
)
./libraries/plugins/auth/recaptcha/ReCaptcha/ReCaptcha.php#94: ReCaptcha\RequestMethod\Post->submit(object)
./libraries/plugins/auth/AuthenticationCookie.class.php#366: ReCaptcha\ReCaptcha->verify(
string '03AHJ_VuvVnV4jlI2mNDNogB6eajU4jE--F7ve',
string '10.0.5.1',
)
./libraries/common.inc.php#896: AuthenticationCookie->authCheck()
./index.php#12: require_once(./libraries/common.inc.php)

所以我想打开phpMyAdmin的allow_url_fopen。我将/etc/php5/apache2/php.ini和/etc/php5/fpm/php.ini更改为

  

allow_url_fopen =开启

     

allow_url_include =开启

根phpinfo显示正确的设置。

Directive           Local Value    Master Value
allow_url_fopen     On             On
allow_url_include   On             On

但是,在phpMyAdmin文件夹中。

Directive           Local Value    Master Value
allow_url_fopen     Off            On
allow_url_include   On             On

所以我尝试在phpMyAdmin文件夹中测试PHP。

  

ini_set(" allow_url_fopen",true);

     

if(ini_get(" allow_url_fopen")== true){echo" allow_url_fopen is ON&#34 ;; }

     

else {echo" allow_url_fopen is OFF&#34 ;; }

     

print ini_get(" allow_url_fopen");

     

print ini_get(" allow_url_include");

     

出口;

allow_url_fopen is OFF01

我还尝试在phpMyAdmin文件夹中添加.htaccess。

  

php_value allow_url_fopen On

为什么在phpMyAdmin文件夹中无法更改本地值?

我的服务器是Debian8.2,PHP5.6.17,phpMyAdmin4.5,MySQL5.7,它位于防火墙后面。

我知道将全局allow_url_fopen设置为On会很危险。我怎样才能将它设置为只在phpMyAdmin文件夹中使用?

1 个答案:

答案 0 :(得分:1)

谢谢Tuan。是的,你是对的。我修改了vhost,现在可以正常工作了。

  

vim /etc/apache2/conf-available/phpmyadmin.conf

     

php_admin_flag allow_url_fopen On

     

php_admin_flag allow_url_include On