open_basedir 限制生效。文件(/)不在允许的路径内:
我在网站上上传头像时遇到此错误。我以前从未得到过它,并且最近没有任何更改让我开始收到此错误......
Warning: is_writable() [function.is-writable]:
open_basedir restriction in effect.
File(/) is not within the allowed path(s):
I'm getting this error on an avatar upload on my site. I've never gotten it before and nothing was changed recently for me to begin getting this error...
Warning: is_writable() [function.is-writable]:
open_basedir restriction in effect.
File(/) is not within the allowed path(s):
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(22)
修改您的托管帐户中的 open_basedir 设置并将其设置为 none。找到 Plesk/cPanel 的“PHP 设置”区域下给出的 open_basedir 设置。从那里给出的下拉列表中将其设置为“无”。
我已经在 Plesk 面板图片中展示了它们。
Modify the open_basedir settings in your hosting account and set them to none. Find the open_basedir setting given under 'PHP Settings' area of your Plesk/cPanel. Set it to 'none' from the dropdown given there.
I have shown them in the Plesk panel picture.
要解决此错误,您必须编辑文件 httpd.conf。
之前可以在 phpinfo 中的 apache2handler 部分指令 Server Root 中看到。
例如我的例子是这样的——/etc/httpd/httpd.conf。
打开文件httpd.conf,找到参数open_basedir。并将其设置为无。 (php_admin_value open_basedir 无)
To resolve this error, you must edit the file httpd.conf.
Way before it can be seen in phpinfo in apache2handler section directive Server Root.
For example, in my case this way - / etc / httpd / httpd.conf.
Open the file httpd.conf, find the mention of the parameter open_basedir. And set it to none. (php_admin_value open_basedir none)
如果您使用
php file.php
运行此程序。您需要编辑php.ini
找到此文件:
并将文件的路径附加到
open_basedir
属性:open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share /webapps/:/etc/webapps/:/run/media/andrew/ext4/protected
If you're running this with
php file.php
. You need to editphp.ini
Find this file:
And append file's path to
open_basedir
property:open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps/:/run/media/andrew/ext4/protected
Laravel
如果你在使用 Laravel 时遇到这个问题。
只需转到文件夹
bootstrap/cache
并将config.php
重命名为您想要的任何内容,然后重新加载站点。Laravel
If you have this problem when using Laravel.
Only go to folder
bootstrap/cache
and renameconfig.php
to anything you want and reload site.对我来说,问题是运行整个过程的 Plesk 服务器的配置值错误/丢失。
我只是按照这里的指示操作:
http://davidseah.com/blog/2007 /04/separate-php-error-logs-for-multiple-domains-with-plesk/
您可以将 PHP 配置为每个 VirtualHost 定义都有一个单独的错误日志文件。诀窍是确切地知道如何设置它,因为您无法在不破坏 Plesk 的情况下直接更改配置。
(dv) 上的每个域名在 /var/www/vhosts 中都有自己的目录。典型的目录具有以下顶级目录:
您需要在域目录的 conf/ 文件夹中创建一个 vhost.conf 文件,其中包含以下行:
更改第一个值以匹配您的实际安装(我使用 /tmp/phperrors.conf)日志)。编辑完 vhost.conf 文件后,从控制台测试配置:
最后告诉 Plesk 您已进行此更改。
For me the problem was bad/missing config values for the Plesk server running the whole thing.
I just followed the directions here:
http://davidseah.com/blog/2007/04/separate-php-error-logs-for-multiple-domains-with-plesk/
You can configure PHP to have a separate error log file for each VirtualHost definition. The trick is knowing exactly how to set it up, because you can’t touch the configuration directly without breaking Plesk.
Every domain name on your (dv) has its own directory in /var/www/vhosts. A typical directory has the following top level directories:
You’ll want to create a vhost.conf file in the domain directory’s conf/ folder with the following lines:
Change the first value to match your actual installation (I used /tmp/phperrors.log). After you’re done editing the vhost.conf file, test the configuration from the console with:
And finally tell Plesk that you’ve made this change.
更新和/或移动后,我在我的 WordPress 网站之一遇到了这个问题。
检查数据库表“wp_options”的“upload_path”并正确编辑它...
I had this problem @ one of my wordpress sites after updating and/or moving.
Check in database table 'wp_options' the 'upload_path' and edit it properly...
如果使用ispconfig3:
和 ”:”
If used ispconfig3:
with ":"
对于 Plesk,您可以通过面板更改或设置 openbase 目录设置
https://support.plesk.com/hc/en-us/articles/360006170513-How-添加自定义或附加路径到 Plesk 域的 open-basedir-option-
For Plesk, you can change or set the openbase dir settings via the panel
https://support.plesk.com/hc/en-us/articles/360006170513-How-to-add-custom-or-additional-path-to-the-open-basedir-option-for-Plesk-domain-
编辑位于主目录中的 php.ini 或 .user.ini
Edit the php.ini or .user.ini that is located within the main directory
您引用的路径不正确,并且不在工作区的目录根范围内。尝试构建您要访问的文件的绝对路径,您现在可能正在使用相对路径...
The path you're refering to is incorect, and not withing the directoryRoot of your workspace. Try building an absolute path the the file you want to access, where you are now probably using a relative path...
我在使用 ispconfig3 时遇到了这种问题,并收到了这样的错误
为了解决我的情况,我只需在 ispconfig3 的网站面板中将 PHP 设置为 SuPHP
I had this kind of problem with ispconfig3 and got an error like this
To solve it in my case, I just set PHP to SuPHP in the Website's panel of ispconfig3
如果您正在运行 PHP IIS 堆栈并遇到此错误,通常可以快速进行权限修复。
如果您自己管理 Windows 服务器并有权访问,请首先尝试此操作:
导航到使您在写入时感到痛苦的文件夹,然后右键单击它 > >打开属性>安全。
查看哪些用户有权访问该文件夹,哪些用户具有只读权限,哪些用户具有完整权限。您是否有一个组阻止写入?
该修复将特定于您的 IIS 设置,您是否使用特定用户 IUSR 或应用程序池身份的匿名身份验证?
无论如何,您最终都会为 IUSR、IIS_IUSRS 或您的应用程序池标识之一添加新的完全写入权限 - 就像我说的,这将根据您的设置以及您想要的方式而有所不同,你可以在这个问题上深入谷歌兔子洞(一篇这样的帖子 - IIS_IUSRS 和IIS8 中的 IUSR 权限)对我来说,我将 anon 与我的应用程序池身份一起使用,这样我就可以使用
MACHINE_NAME\IIS_IUSRS
对任何临时或上传文件夹进行完全读/写。我不需要向 php.ini 中的
open_basedir =
添加任何额外内容。If you are running a PHP IIS stack and have this error, it is usually a quick permission fix.
If you administer the windows server yourself and have access, try this FIRST:
Navigate to the folder that is giving you grief on writing to and right click it > open properties > security.
See what users have access to the folder, which ones have read only and which have full. Do you have a group that is blocking write?
The fix will be specific to your IIS setup, are you using Anonymous Authentication with specific user IUSR or with the Application Pool identity?
At any rate, you are going to end up adding a new full write permission for one of IUSR, IIS_IUSRS, or your application pool identity - like I said, this is going to vary depending on your setup and how you want to do it, you can go down the google rabbit hole on this one (one such post - IIS_IUSRS and IUSR permissions in IIS8) For me, i use anon with my app pool identity so i can get away with
MACHINE_NAME\IIS_IUSRS
with full read/write on any temp or upload folders.I do not need to add anything extra to my
open_basedir =
in the php.ini.除了@yogihosting的回答之外,如果您使用DirectAdmin,请按照以下步骤
admin
。在页面顶部的文本区域中输入您要更改的配置。您应该考虑现有的配置文件并根据它修改值。例如,如果您发现
open_basedir
设置在
内,也许您应该将您的更改包含在相关的
中> 标签:进行必要的更改后,单击“保存”按钮。
不过,还有另一种编辑配置文件的方法:
警告:请务必小心,并自行承担使用以下步骤的风险,因为您可能会遇到错误,或者可能导致停机。推荐的方法是前一种,因为它可以防止您错误地修改配置文件并显示错误。
/usr/local/directadmin/data/users
。从列出的用户中,转到与您要更改的域相关的用户。这里有一个
httpd.conf
文件。从中进行备份:现在使用您选择的编辑器编辑配置文件。例如,将现有的
open_basedir
编辑为none
。不要尝试删除任何东西,否则您可能会遇到停机。编辑后保存文件。使用以下方法之一重新启动 Apache Web 服务器(如果需要,请使用
sudo
):如果遇到任何错误,请将主配置文件替换为备份文件,然后重新启动 Web 服务器。
再次强调,第一个解决方案是首选,您不应该在第一次尝试第二种方法。正如警告中所指出的,第一种方法的优点是它可以防止保存错误配置的内容。
希望有帮助!
In addition to @yogihosting's answer, if you are using DirectAdmin, then follow these steps:
admin
by default.Enter the configurations you want to change in the textarea at the top of the page. You should consider the existing configuration file and modify values based on it. For example, if you see that
open_basedir
is set inside a<Directory>
, maybe you should surround your change in the related<Directory>
tag:After making necessary changes, click on the "Save" button.
There is another way of editing the configuration file, however:
Caution: Be careful, and use the following steps at your own risk, as you may run into errors, or it may lead to downtime. The recommended way is the previous one, as it prevents you from modifying configuration file improperly and show you the error.
/usr/local/directadmin/data/users
. From the listed users, go to one related to the domain you want to change.Here, there is an
httpd.conf
file. Make a backup from it:Now edit the configuration file with your editor of choice. For example, edit existing
open_basedir
tonone
. Do not try to remove things, or you may experience downtime. Save the file after editing.Restart the Apache web server using one of the following ways (use
sudo
if needed):If your encounter any errors, then replace the main configuration file with the backed-up file, and restart the web server.
Again, the first solution is the preferred one, and you should not try the second method at the first time. As it is noted in the caution, the advantage of the first way is that it prevents saving your bad-configured stuff.
Hope it helps!
我正在使用 Apache vhost-File 在 Windows 服务器上运行带有特定于应用程序的 ini 选项的 PHP。因此我使用 php 命令的 -d 选项。
我为每个应用程序设置 open_basedir 作为这些选项之一。
我需要将多个 url 设置为 open_basedir,包括 UNC-Path,并且这种情况的语法有点难以找到。您必须用分号分隔路径,如果您的第一个路径以驱动器盘符开头,您可能也必须以分号开始列表。至少这对我有用。
例子:
I am using an Apache vhost-File to run PHP with application-specific ini-options on my windows-server. Therefore I use the -d option of the php-command.
I am setting the open_basedir for every application as one of these options.
I needed to set multiple urls as open_basedir, including an UNC-Path, and the syntax for this case was a bit hard to find. You have to seperate the paths with semicolons and if your first path starts with a driveletter you might have to start the list with a semicolon too. At least that's what works for me.
Example:
我在 Directadmin 面板上上传了我的 codeigniter 项目。我遇到了同样的错误。
然后我更改 php 设置。
open_basedir =
session.save_path = ./temp/
然后它对我有用。
I uploaded my codeigniter project on Directadmin panel. I was getting same error.
Then I change in php settings.
open_basedir =
session.save_path = ./temp/
Then it worked for me.
由于大多数人都没有找到解决方案,因此 WordPress 的解决方案很广泛,大多数人甚至不完全知道为什么会这样。
我发现你必须为你的服务器启用 IP,特别是在使用 Cerber 时,在某些情况下它可能会认为你没有上传 .png,而是上传 .js 文件。
服务器IP需要加入白名单。在极少数情况下,甚至上传者也是如此。
很高兴知道的是在您的基本目录中有一个 tmp 文件夹 755,您实际上不需要一个名为 tmp 的文件夹。:“另请记住/正确编辑如下:
快速设置的最佳选项是在使用 MultiPHP 的 Cpanel 中您实际上可以保存 INI 编辑器,并且 .htaccess 和 php.ini 都将被更新,并且站点上同时启动设置。
不建议将 basedir 设置为“none”,因为您正在启用可编辑的根文件。如果这真的可能的话,只需在 WordPress 中使用一个文件编辑器即可。
As most do not find a solution, the solutions are broad for WordPress most even don't know fully why things are they are.
I've found out you will have to enable IP for your server in especially when using Cerber in some cases it can think you are not uploading .png instead you are uploading .js files.
The server IP needs to be whitelisted. Even the uploaders in some rare cases.
A great to know is to have a tmp folder 755 in your base directory, you actually do not need a folder called tmp.: "Also remember / properly inedited as below:
The best option for quick setup is in Cpanel where you use the MultiPHP INI Editor you can actually save and both .htaccess and php.ini will be updated as well as settings being initiated at the same time on site.
It's NOT recommended to have basedir as "none" since you are enabling root files that can be edited with just a single file editor in WordPress. If that truly is possible.
对我来说,这是因为我在 php.ini 的 tmp 目录中给出了错误的路径。
希望这有帮助
For me it is because I gave the wrong path in the tmp directory of php.
Hope this helps
当我使用
Imagick
将图像转换为.avif
格式时,出现此错误。解决方案是使用
__DIR__
,如下所示:我希望它可以帮助某人。
I got this error when I used
Imagick
for converting image to.avif
format.Solution was to use
__DIR__
, like this:I hope it helps someone.
如果使用 cPanel,请选择“选择 PHP 版本”> “选项”
用冒号 (:) 分隔的所有允许的目录更新 open_basedir。
例如:
/home/website/public_html:/home/website/config
我遇到此问题是因为我在 cPanel 帐户中使用了第二个域。当我在第二个域上安装 wordpress 时,它无法访问该目录,直到我更新它。
If using cPanel choose "Select PHP Version" > "Options"
Update open_basedir with all allowed directories separated by a colon (:).
ex:
/home/website/public_html:/home/website/config
I was having this issue because I was using a second domain in my cPanel account. When I installed wordpress on the second domain, it wasn't able to access the directory until I updated this.
检查 plesk 中的 \httpdocs\bootstrap\cache\config.php 文件,看看是否有一些不需要的路径。
Check \httpdocs\bootstrap\cache\config.php file in plesk to see if there are some unwanted paths.
只需搜索
在 php.ini 中并禁用它。这是解决这个问题的最简单的解决方案。
更改前
open_basedir =
更改后
;open_basedir =
Ps - 更改后不要忘记重新启动服务器。
享受 ;)
Just search
in php.ini and disable it. That's the simplest solution to solve this issue.
Before Changes
open_basedir =
After Changes
;open_basedir =
P.s - After changes don't forget to restart your server.
Enjoy ;)
修改
open_basedir
设置< /a> 在您的 PHP 配置中(请参阅运行时配置)。open_basedir
设置主要用于防止特定用户的 PHP 脚本访问其他用户帐户中的文件。因此,通常情况下,您自己帐户中的任何文件都应该可由您自己的脚本读取。如果 PHP 在 Linux 系统上作为 Apache 模块运行,则通过
.htaccess
设置示例:Modify the
open_basedir
settings in your PHP configuration (See Runtime Configuration).The
open_basedir
setting is primarily used to prevent PHP scripts for a particular user from accessing files in another user's account. So usually, any files in your own account should be readable by your own scripts.Example settings via
.htaccess
if PHP runs as Apache module on a Linux system: