“FAQ:MediaWiki”的版本间差异

来自Wikioe
跳到导航 跳到搜索
无编辑摘要
第4行: 第4行:
<div align="center"><span style="font-weight:bold; font-size:150%;"> [https://www.mediawiki.org/wiki/Manual:FAQ/zh 手册:常见问题] </span></div>
<div align="center"><span style="font-weight:bold; font-size:150%;"> [https://www.mediawiki.org/wiki/Manual:FAQ/zh 手册:常见问题] </span></div>


== “open_basedir restriction in effect” ==
== '''open_basedir''' 问题 ==
* '''错误:''' '''<code>Warning: is_executable(): open_basedir restriction in effect. File(/bin/bash) is not within the allowed path(s): (/www/wwwroot/wiki.eijux.com/:/tmp/) in /www/wwwroot/wiki.eijux.com/includes/shell/Command.php on line 311</code>'''。<br/>
错误信息:<span style="color: red; font-size: 100%">'''Warning: is_executable(): open_basedir restriction in effect.''' File(/bin/bash) is not within the allowed path(s): (/www/wwwroot/wiki.eijux.com/:/tmp/) in /www/wwwroot/wiki.eijux.com/includes/shell/Command.php on line 311</span>
分析:出现此类问题一般为open_basedir的问题,即访问的文件不在'''<code>open_basedir</code>'''的限定目录里面'''(<code>open_basedir</code>的作用是将php所能打开的文件限制在指定的目录或文件,防止跨目录、跨站的访问)'''。
 
<blockquote>
<span style="color: blue; font-size: 120%">'''open_basedir(防止跨站攻击)'''</span> :用于'''将 PHP 所能打开的文件限制在指定的目录树''',以此防止跨目录、跨站的访问。
 
1、本指令不受安全模式打开或者关闭的影响。
 
2、当一个脚本试图打开一个文件时,该文件的位置将被检查。
 
3、当文件在指定的目录树之外时 PHP 将拒绝打开它。
</blockquote>
 
'''解决方式:'''
# 关闭“防止跨站攻击”,在<span style="color: blue">宝塔面板</span>中:网站 -> 站点设置 -> 网站目录:取消“防止跨站攻击(open_basedir)”。如下图:
#:
# 配置“open_basedir”,
 
 
* '''错误:''' '''<code></code>'''。<br/>
分析:出现此类问题一般为 open_basedir 的问题,即访问的文件不在'''<code>open_basedir</code>'''的限定目录里面'''(<code>open_basedir</code>的作用是将php所能打开的文件限制在指定的目录或文件,)'''。
* '''处理:'''
* '''处理:'''


第41行: 第59行:
设置'''<code>open_basedir</code>'''对此有效。之前解析'''<code>.svg</code>'''、使用'''<code>syntaxhighlight</code>'''遇到此问题时,还有确实依赖的库、服务的问题需要解决,此备忘。
设置'''<code>open_basedir</code>'''对此有效。之前解析'''<code>.svg</code>'''、使用'''<code>syntaxhighlight</code>'''遇到此问题时,还有确实依赖的库、服务的问题需要解决,此备忘。
</div>
</div>


== 无法生成avg缩略图 ==
== 无法生成avg缩略图 ==

2022年8月23日 (二) 15:00的版本


关于

手册:常见问题

open_basedir 问题

错误信息:Warning: is_executable(): open_basedir restriction in effect. File(/bin/bash) is not within the allowed path(s): (/www/wwwroot/wiki.eijux.com/:/tmp/) in /www/wwwroot/wiki.eijux.com/includes/shell/Command.php on line 311

open_basedir(防止跨站攻击) :用于将 PHP 所能打开的文件限制在指定的目录树,以此防止跨目录、跨站的访问。

1、本指令不受安全模式打开或者关闭的影响。

2、当一个脚本试图打开一个文件时,该文件的位置将被检查。

3、当文件在指定的目录树之外时 PHP 将拒绝打开它。

解决方式:

  1. 关闭“防止跨站攻击”,在宝塔面板中:网站 -> 站点设置 -> 网站目录:取消“防止跨站攻击(open_basedir)”。如下图:
  2. 配置“open_basedir”,


  • 错误:

分析:出现此类问题一般为 open_basedir 的问题,即访问的文件不在open_basedir的限定目录里面open_basedir的作用是将php所能打开的文件限制在指定的目录或文件,)

  • 处理:

修改php配置

查阅PHP配置文件php.ini搜索open_basedir,添加配置如下:

; open_basedir, if set, limits all file operations to the defined directory
; and below.  This directive makes most sense if used in a per-directory
; or per-virtualhost web server configuration file.
; Note: disables the realpath cache
; http://php.net/open-basedir
; open_basedir =
open_basedir = /www/wwwroot/wiki.eijux.com/:/tmp/

结果还是搞不定!

BTPanel防跨站攻击

上网搜索一番才发现,BTPanel中站点设置的“网站目录”中有“防跨站攻击(open_basedir)”的选项,取消勾选之后,重启PHP,就不再有这错误了。
(该选项的配置文件为:“/www/server/panel/vhost/openlitespeed/detail/wiki.eijux.com.conf”),取消勾选即注释了代码:

phpIniOverride  {
#php_admin_value open_basedir "/tmp/:/www/wwwroot/wiki.eijux.com/" 
}
  • 注意:

注意用open_basedir 指定的限制是路径前缀,而非目录名。所以如果要将访问限制在仅为指定的目录,应用斜线结束路径名。
如:若"open_basedir = /dir/user", 那么目录 "/dir/user""/dir/user1"都是可以访问的。

设置open_basedir对此有效。之前解析.svg、使用syntaxhighlight遇到此问题时,还有确实依赖的库、服务的问题需要解决,此备忘。

无法生成avg缩略图

如果要使用第三方的converter,参见Image thumbnailing页面

  • 描述:

上传.svg文件过后,页面中提示“生成缩略图出错:无法创建临时缩略图文件”,在“特殊页面:文件列表”中查看文件时: Warning: symlink() has been disabled for security reasons in /www/wwwroot/wiki.eijux.com/includes/media/SvgHandler.php on line 280

  • 处理:

默认安装的PHP一些函数是没有默认开启的。 我们需要的函数是symlink(),则用在PHP的禁用函数中删除该函数即可。


  • 描述:

生成缩略图处提示:sh: convert: command not found,PHP错误信息为Warning: is_executable(): open_basedir restriction in effect. File(/bin/bash) is not within the allowed path(s): (/www/wwwroot/wiki.eijux.com/:/tmp/) in /www/wwwroot/wiki.eijux.com/includes/shell/Command.php on line 311

  • 处理:

先考虑是PHP配置的问题,

PHP错误'''require(): open_basedir restriction in effect”''',即访问脚本不在'''<code>open_basedir</code>'''的限定目录里面,'''<code>open_basedir</code>'''的作用是将php所能打开的文件限制在指定的目录或文件。<br/>

修改PHP配置文件PHP.iniopen_basedir之后错误依旧,而后一直都盯着open_basedir打转。兜兜转转许久才注意到sh: convert: command not found的提示,想到可能没有配置Svg Converter,从而进一步发现MediaWiki没有默认安装Converter。最后在| 官网手册SVG节了解到支持信息,相关的Converter("ImageMagick", "ImagickExt", "sodipodi", "inkscape", "batik", "rsvg", and "imgserv")均需单独安装。相较之下,选用了| NativeSvgHandler扩展(将SVG文件直接发送至客户端以进行客户端渲染)。步骤如下:

  1. 下载文件,并将其放置在extensions/文件夹中的NativeSvgHandler目录内。(注意修改所有者及读写权限)
  2. 将下列代码放置在您的LocalSettings.php的底部:'wfLoadExtension( 'NativeSvgHandler' );'
  3. 导航至Special:Version,以验证扩展已成功安装。

再于网页刷新,svg缩略图显示正常。