共享主机上的 Laravel file_put_contents 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47080756/
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 16:54:38  来源:igfitidea点击:

Laravel file_put_contents error on shared hosting

phplaravel

提问by Martin Yakimov

I created my Laravel app and I am uploading on shared hosting. It's show error:

我创建了我的 Laravel 应用程序,我正在共享主机上上传。这是显示错误:

file_put_contents(D:\xampp\htdocs\Laravel\storage\framework/sessions/FlEPsHNW7Rggfb9wvDZ71K7D2YQNNQK0epRBRQnW): failed to open stream: No such file or directory

file_put_contents(D:\xampp\htdocs\Laravel\storage\framework/sessions/FlEPsHNW7Rggfb9wvDZ71K7D2YQNNQK0epRBRQnW):无法打开流:没有这样的文件或目录

This is folder from my computer. I read same problems but I am on shared hosting and I don't have a composer or artisan for operations.

这是我电脑上的文件夹。我读到了同样的问题,但我在共享主机上,我没有作曲家或操作工匠。

Thanks in advance!

提前致谢!

回答by Marcin Nabia?ek

What you should do is looking for occurrences of xamppin your application because it seems you have sessions are written to same folder that you have on your machine and obviously such directory doesn't exist on web server.

您应该做的是xampp在您的应用程序中查找出现的次数,因为您的会话似乎已写入您计算机上的同一文件夹中,并且显然此类目录在 Web 服务器上不存在。

Especially make sure you in session.phpyou have:

尤其要确保session.php您拥有:

'files' => storage_path('framework/sessions'),

and remove config cache from bootstrap/cachedirectory just in case

并从bootstrap/cache目录中删除配置缓存以防万一

回答by zonecc

I had the same issue here. I tried to run php artisan config:cachebut it didn't work out

我在这里遇到了同样的问题。我试图跑,php artisan config:cache但没有成功

Then I delete all my sessions in /myprojectname/storage/framework/but still didn't work out on shared hosting but worked fine on localhost.

然后我删除了所有会话,/myprojectname/storage/framework/但在共享主机上仍然无法正常工作,但在本地主机上工作正常。

Here's what worked:

这是有效的:

I delete the cache folder in /myprojectname/bootstrap/and ran the application and got this error:

我删除了缓存文件夹/myprojectname/bootstrap/并运行了应用程序并收到此错误:

Exception thrown with message "The /hosthome/hostuser/myprojectname/bootstrap/cache directory must be present and writable."

I then made a new cache folder in /myprojectname/bootstrap/and ran the site and it was up

然后我在其中创建了一个新的缓存文件夹/myprojectname/bootstrap/并运行该站点并且它已启动

in short terms

短期内

  • Navigate to your projects /bootstrap/cache/folder.

  • Delete the contents of the directory and your good to go

  • 导航到您的项目/bootstrap/cache/文件夹。

  • 删除目录中的内容,一切顺利

回答by San K

Change config path and make sure storage folder has correct permission Directory Permissions

更改配置路径并确保存储文件夹具有正确的权限 目录权限

After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run. If you are using the Homestead virtual machine, these permissions should already be set.

安装 Laravel 后,您可能需要配置一些权限。storage 和 bootstrap/cache 目录中的目录应该可以被你的 web 服务器写入,否则 Laravel 将无法运行。如果你使用的是 Homestead 虚拟机,这些权限应该已经设置好了。