在网站上安装 MediaWiki 结束后显示 Warning: Cannot modify header information 如何解决?

2018-10-05 03:16:51 +08:00
 Taxila

在安装 MediaWiki 时显示警告:

Warning: putenv() has been disabled for security reasons in /storage/ssd1/808/4772808/public_html/includes/Setup.php on line 129

但是不影响 MediaWiki 的安装。

安装完成后,本来应该正常显示的网站主页只出现了如下报错代码:

Warning: putenv() has been disabled for security reasons in /storage/ssd1/808/4772808/public_html/includes/Setup.php on line 129

Warning: putenv() has been disabled for security reasons in /storage/ssd1/808/4772808/public_html/includes/Setup.php on line 129

Warning: Cannot modify header information - headers already sent by (output started at /storage/ssd1/808/4772808/public_html/LocalSettings.php:1) in /storage/ssd1/808/4772808/public_html/includes/libs/HttpStatus.php on line 112

Warning: Cannot modify header information - headers already sent by (output started at /storage/ssd1/808/4772808/public_html/LocalSettings.php:1) in /storage/ssd1/808/4772808/public_html/includes/WebResponse.php on line 46

Warning: Cannot modify header information - headers already sent by (output started at /storage/ssd1/808/4772808/public_html/LocalSettings.php:1) in /storage/ssd1/808/4772808/public_html/includes/WebResponse.php on line 46

Warning: Cannot modify header information - headers already sent by (output started at /storage/ssd1/808/4772808/public_html/LocalSettings.php:1) in /storage/ssd1/808/4772808/public_html/includes/WebResponse.php on line 46

Warning: Cannot modify header information - headers already sent by (output started at /storage/ssd1/808/4772808/public_html/LocalSettings.php:1) in /storage/ssd1/808/4772808/public_html/includes/WebResponse.php on line 46

Warning: Cannot modify header information - headers already sent by (output started at /storage/ssd1/808/4772808/public_html/LocalSettings.php:1) in /storage/ssd1/808/4772808/public_html/includes/WebResponse.php on line 46

Warning: Cannot modify header information - headers already sent by (output started at /storage/ssd1/808/4772808/public_html/LocalSettings.php:1) in /storage/ssd1/808/4772808/public_html/includes/WebResponse.php on line 46

楼主并非程序员,更没有 PHP 经验,只能摸索着试图解决。在网上看到有人说可以修改 PHP.ini 中“输出缓冲区数据块设置”解决,但在网站的空间内没有找到这个文件。托管商提供了 phpMyAdmin 工具,但是也并没有找到可以解决这个问题的地方,万般无奈之下只好来这里求助了,希望有人能指点迷津,不胜感激之至!

3503 次点击
所在节点    PHP
13 条回复
muzhidianzi
2018-10-05 04:04:02 +08:00
也是新手 野路子出身 萌新抛砖引玉下 貌似是 PHP 安全模式? 部分函数被禁用了,需要去 php 的配置文件 php.ini 里禁用安全模式 看楼主描述貌似购买的是空间而不是 vps 或者服务器?这样应该是接触不到配置文件无法修改的。

此外 phpmyadmin 是一个基于 php 的 web 端数据库管理程序 只是基于 php 而已

有说错地方各位大佬斧正
ysc3839
2018-10-05 04:04:04 +08:00
关闭错误输出试试。一般情况下非开发环境不应该开启错误输出,以免泄漏敏感信息。
muzhidianzi
2018-10-05 04:08:26 +08:00
话说去 Google 的这个函数,居然搜到这个帖子,蜘蛛爬的真勤快
580a388da131
2018-10-05 09:22:00 +08:00
Warning: putenv() has been disabled
它不是说了函数 putenv() 被禁用了么
Taxila
2018-10-05 10:01:45 +08:00
@muzhidianzi 确实是空间而非服务器。查了一下确实没法改 php.ini ,但是可以改 .htaccess …
Taxila
2018-10-05 10:02:08 +08:00
@ysc3839 关闭错误输出应该去哪里关闭呢?
muzhidianzi
2018-10-05 10:39:16 +08:00
Taxila
2018-10-05 11:17:00 +08:00
目前通过 https://www.mddhosting.com/support/knowledgebase/115/PHP---Cannot-modify-header-information---headers-already-sent-by-.html 给出的解决代码已经消除了 Warning: Cannot modify header information 警告,并且能够正常打开页面了。

但是页面上方依然有一行 Warning: putenv() has been disabled for security reasons in /storage/ssd1/808/4772808/public_html/includes/Setup.php on line 129 即使用到了 @muzhidianzi 给的代码也没法消除,还是令人不爽。
RiESA
2018-10-05 11:22:43 +08:00
@Taxila #8 用同样的方式关闭 display_errors 试试看?
RiESA
2018-10-05 11:32:57 +08:00
; display_errors
; Default Value: On
; Development Value: On
; Production Value: Off

; display_startup_errors
; Default Value: Off
; Development Value: On
; Production Value: Off

; error_reporting
; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT

; html_errors
; Default Value: On
; Development Value: On
; Production value: On

; log_errors
; Default Value: Off
; Development Value: On
; Production Value: On
RiESA
2018-10-05 11:34:03 +08:00
我之前安装的时候也遇到过,不过我是通过修改 php.ini 处理的,上面是我目前的设置,你可以参考一下
Taxila
2018-10-05 11:59:03 +08:00
@RiESA 这里给出的代码是 php.ini 里面的吗?
RiESA
2018-10-05 12:22:44 +08:00
@Taxila 是的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/494968

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX