FAQ:WordPress

来自Wikioe
跳到导航 跳到搜索


open_basedir 问题[1]

安装 WordPress 之后,遇到了 open_basedir 的问题:
 
Warning: is_readable(): open_basedir restriction in effect. File(/devowl-wp-utils-zh_CN-270b7888271dde223c8821bf704b0c6f.json) is not within the allowed path(s): (/www/wwwroot/:/www/wwwroot/eijux.com/:/tmp/) in /www/wwwroot/eijux.com/wp-content/plugins/real-media-library/vendor/devowl-wp/utils/src/Localization.php on line 62

Warning: is_readable(): open_basedir restriction in effect. File(/devowl-wp-utils-zh_CN-devowl-wp-utils.json) is not within the allowed path(s): (/www/wwwroot/:/www/wwwroot/eijux.com/:/tmp/) in /www/wwwroot/eijux.com/wp-content/plugins/real-media-library/vendor/devowl-wp/utils/src/Localization.php on line 62

Warning: is_readable(): open_basedir restriction in effect. File(/devowl-wp-utils-zh_CN-7364056391583b3779afc7f5e48df690.json) is not within the allowed path(s): (/www/wwwroot/:/www/wwwroot/eijux.com/:/tmp/) in /www/wwwroot/eijux.com/wp-content/plugins/real-media-library/vendor/devowl-wp/utils/src/Localization.php on line 62

Warning: is_readable(): open_basedir restriction in effect. File(/devowl-wp-utils-zh_CN-vendor-devowl-wp-utils.json) is not within the allowed path(s): (/www/wwwroot/:/www/wwwroot/eijux.com/:/tmp/) in /www/wwwroot/eijux.com/wp-content/plugins/real-media-library/vendor/devowl-wp/utils/src/Localization.php on line 62

如图:

WordPress:open basedir问题.png

备注

  • 【2022/08/23 19:23:20】和 FAQ:MediaWiki#open_basedir 问题 一样的问题,但是不一样的情况:
    此处,提示未在“open_basedir”之内的目录,均是在服务器根目录:
    根目录当然找不到上述内容【猜测是由代码生成的临时脚本???可能需要调整代码???】
    若将“/”添加到“open_basedir”,的确能“解决”此问题,但是“防止跨站攻击”就毫无意义。
    所以只能:关闭站点的“防止跨站攻击”

WordPress上传附件限制

在WordPress上传时提示“超过了最大限制”,如图:

Wordpress上传页面.png

解决方法有四:

  1. 修改服务器nginxphp设置,并分别重启;(服务器有多个站点时不考虑直接修改nginx和php配置)【???也不好使!!!2020/09/29 22:46:37】
    Nginx上传文件限制.pngPhp上传文件限制.png
  2. functions.php(位于“eijux.com/wp-includes”下)中添加如下代码:【这个写法和function.php的内容格式差太远,2020/09/29 21:30:00】
    @ini_set( 'upload_max_size' , '64M' );
    @ini_set( 'post_max_size', '64M');
    @ini_set( 'max_execution_time', '300' );
    
  3. 在网站根目录新建php.ini文件:【修改后重启了nginx、php及站点,然而并不起作用,2020/09/29 21:30:13】
    upload_max_filesize = 64M
    post_max_size = 64M
    max_execution_time = 300
    
  4. 在网站根目录的.htaccess文件中添加:【不起作用,2020/09/29 21:32:13】
    php_value upload_max_filesize 64M
    php_value post_max_size 64M
    php_value max_execution_time 300
    php_value max_input_time 300
    

解决“超过了站点的最大上传限制”

修改php配置(nginx配置似乎无效)(wordpress上传文件限制是由PHP的环境配置决定的):

  • post_max_size = 500M:POST数据最大尺寸(大于等于upload_max_filesize);
  • upload_max_filesize = 200M:允许上传文件的最大尺寸(单文件大小的限制);

解决“从服务器收到预料之外的响应”

“从服务器收到预料之外的响应。此文件可能已被成功上传。请检查媒体库或刷新本页。”

修改nginx配置:

  • client_max_body_size = 200M:nginx允许的最大上传文件;