laravel file_put_contents():此流不支持排他锁

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47921408/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:08:26  来源:igfitidea点击:

laravel file_put_contents(): Exclusive locks are not supported for this stream

laravel

提问by Thiraj Priyadharshana

I tried to upload my site to laravel to host and be configured but I couldn't load the project. The error is as follows:

我尝试将我的网站上传到 Laravel 以进行托管和配置,但无法加载该项目。错误如下:

file_put_contents(): Exclusive locks are not supported for this stream

file_put_contents():此流不支持排他锁

How do I fix this?

我该如何解决?

回答by Fabian

The problem is that the host is not supporting "exlusive locks". I had this problem with Vagrant on a Ubuntu host. Then you can fix it like described here: https://stackoverflow.com/a/35743592/2707570If you have the problem on a remote server you need to contact the provider and ask why exclusive locks are not supported.

问题是主机不支持“排他锁”。我在 Ubuntu 主机上遇到了 Vagrant 的这个问题。然后您可以像这里描述的那样修复它:https: //stackoverflow.com/a/35743592/2707570如果您在远程服务器上遇到问题,您需要联系提供商并询问为什么不支持排他锁。

回答by Dunsin Olubobokun

I had a similar issue recently. Running the artisan command: php artisan config:cachefixed it for me

我最近遇到了类似的问题。运行 artisan 命令:php artisan config:cache为我修复了它

回答by Gideon Macha

Try to remove the following line of code in your path:

尝试删除路径中的以下代码行:

public function put($path, $contents, $lock = false)
    {
        return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
    }

and replace it with this one below:-

并用下面的替换它:-

public function put($path, $contents, $lock = false)
{
    return file_put_contents($path, $contents, 0);
}

回答by Stefanos Kargas

I had the same error, while using NFS to share my code from my developer machine to my Centos server. The problem seems to be that the server tried to access my NFS-shared files using NLM locking by default, so I had to disable locking in my settings. This is done by adding nolockin the NFS options in /etc/fstab

我遇到了同样的错误,同时使用 NFS 将我的代码从我的开发人员机器共享到我的 Centos 服务器。问题似乎是服务器默认尝试使用 NLM 锁定访问我的 NFS 共享文件,因此我不得不在我的设置中禁用锁定。这是通过添加nolockNFS 选项来完成的/etc/fstab

This fixed the issue for me

这为我解决了问题

回答by Brainsworld Developers

  1. You have to close the server by closing your batch window you used in starting the server initially.

  2. Refresh your browser and make sure the the server has been closed.

  3. Start a new development server by typing $ php artisan serve

  4. Go to your browser and enter the server address generated by the artisan. It's usually http://127.0.0.1:8000

  1. 您必须通过关闭最初用于启动服务器的批处理窗口来关闭服务器。

  2. 刷新浏览器并确保服务器已关闭。

  3. 通过键入启动一个新的开发服务器 $ php artisan serve

  4. 转到您的浏览器并输入由工匠生成的服务器地址。通常是http://127.0.0.1:8000