【问题标题】:allow_url_fopen local variableallow_url_fopen 局部变量
【发布时间】:2016-06-16 04:48:35
【问题描述】:

我通过添加两个变量在 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 为 ON"; }

else { echo "allow_url_fopen 关闭"; }

打印 ini_get("allow_url_fopen");

打印 ini_get("allow_url_include");

退出;

allow_url_fopen is OFF01

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

php_value allow_url_fopen 开启

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

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

我知道将全局 allow_url_fopen 设置为 On 很危险。如何将其设置为仅对 phpMyAdmin 文件夹可用?

【问题讨论】:

  • 由于安全问题,您不能即时更改此标志。你需要检查你的 php.ini 配置(php.ini 文件和 webserver 配置中的 php 标志)
  • 所以您的意思是更改 /etc/php5/apache2/php5.ini 中的配置?我更改了根文件夹,但 phpmyadmin 文件夹不起作用。
  • vhost 文件怎么样? PHP标志有什么变化吗?

标签: php phpmyadmin recaptcha


【解决方案1】:

谢谢段。是的,你是对的。我修改了虚拟主机,它现在可以工作了。

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

php_admin_flag allow_url_fopen 开启

php_admin_flag allow_url_include 开启

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-07-24
    • 2017-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多