php Laravel 中的存储表示符号链接 - 没有这样的文件

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

Storage in laravel says symlink - no such file

phplaravel

提问by Programmmereg

I deployed laravel app on shared hosting in public_html/app folder. Here is everything from public folder. In /../../files I have rest of files. When I do php artisan storage:link in files folder my console says

我在 public_html/app 文件夹中的共享主机上部署了 laravel 应用程序。这是公共文件夹中的所有内容。在 /../../files 我有其余的文件。当我执行 php artisan storage:link in files 文件夹时,我的控制台说

[ErrorException]                      
  symlink(): No such file or directory

On localhost I upload files to storage/uploads folder. What to do now? I tried to change links but nothing works for me...

在本地主机上,我将文件上传到存储/上传文件夹。现在做什么?我试图更改链接,但对我没有任何作用...

回答by Turan Zamanl?

  1. Go to /publicdirectory and run:

    rm storage

  2. Go to Laravel root directory and run:

    php artisan storage:link

  1. 转到/public目录并运行:

    rm storage

  2. 转到 Laravel 根目录并运行:

    php artisan storage:link



Edited on May 1st 2018

2018 年 5 月 1 日编辑

This problem comes when laravel project is moved/copied to some other folder.

当 laravel 项目被移动/复制到其他文件夹时,就会出现这个问题。

The storage link is still there thus causing the exception error. public/storage folder exists and points to wrong location and it needs to be deleted with rm storagecommand.

存储链接仍然存在,从而导致异常错误。public/storage 文件夹存在并指向错误的位置,需要使用rm storage命令将其删除。

After that run php artisan storage:linkin terminal and it will create the storage link.

之后php artisan storage:link在终端中运行,它将创建存储链接。

This needs to be done EVERY time when laravel is moved/copied/deployed!

每次移动/复制/部署 Laravel 时都需要这样做!

回答by Al-Amin

I'm face same error when use share hosting and my public directory move to public_html or different directory like : project directory in root name "project" and public directory in root name "public_html"

使用共享托管时我面临同样的错误,我的公共目录移动到 public_html 或不同的目录,如:根名称“project”中的项目目录和根名称“public_html”中的公共目录

when run artisan command by Artisan::call('storage:link'); then face this error.

当通过 Artisan::call('storage:link') 运行 artisan 命令时;然后面对这个错误。

Solution: 1st need to bind your public directory in app/Providers/AppServiceProvider register method

解决方案:1st 需要在 app/Providers/AppServiceProvider 注册方法中绑定您的公共目录

 $this->app->bind('path.public', function() {
    return base_path('../public_html');
 });

Now run the command its working fine

现在运行命令它工作正常

回答by A Garhy

This usually happens after moving Laravel app to another directory

这通常发生在将 Laravel 应用程序移动到另一个目录之后

The actual storage directory is "/AppName/storage/app/public/"

实际存储目录为“/AppName/storage/app/public/”

Laravel creates a symbolic link pointing to actual storage dir "/AppName/public/storage"

Laravel 创建一个指向实际存储目录“/AppName/public/storage”的符号链接

Other meaning

其他含义

"/AppName/public/storage" points to => "/AppName/storage/app/public/"

"/AppName/public/storage" 指向 => "/AppName/storage/app/public/"

On changing root app directory to "/AnotherAppName/" symlink will still point to the old path

将根应用程序目录更改为“/AnotherAppName/”符号链接仍将指向旧路径

"/AnotherAppName/public/storage" => "/AppName/storage/app/public/"

"/AnotherAppName/public/storage" => "/AppName/storage/app/public/"

my solution is to manually update the symlink using

我的解决方案是使用手动更新符号链接

ln -sfn /AnotherAppName/storage/app/public/ /AnotherAppName/public/storage

回答by ali javan

create new php file and put this code on the file:

创建新的 php 文件并将此代码放在文件中:

<?php
symlink('/home/CpanelUser/storage/app/public', '/home/CpanelUserpublic_html/storage');
?>

"CpanelUser" change to youre cpanel user name or host name.

“CpanelUser”更改为您的 cpanel 用户名或主机名。

Upload this file to public_html folder (www) of site execute file with write site name+this file in browser done!

将此文件上传到站点执行文件的public_html文件夹(www),并在浏览器中写入站点名称+此文件!

Example: My file name is symlink.php and site name is www.anysite.com upload symlink.php to public_html folder in host and get web address in browser

示例:我的文件名为 symlink.php,站点名为 www.anysite.com 将 symlink.php 上传到主机中的 public_html 文件夹并在浏览器中获取网址

http://www.anysite.com/symlink.php

http://www.anysite.com/symlink.php

after execute this file storage folder creite in public folder in laravel and link to storage folder in app.

在laravel的公共文件夹中执行此文件存储文件夹creite并链接到应用程序中的存储文件夹后。

回答by ahmedkandil

Delete the existing storage symbolic link (public/storage) and then run php artisan storage:linkcommand again.

删除现有的存储符号链接 ( public/storage),然后php artisan storage:link再次运行 命令。

回答by Clemence Ayekple

To fix this error on your server, change directory to the public and remove the symbolic link for the storage folder.

要在您的服务器上修复此错误,请将目录更改为 public 并删除存储文件夹的符号链接。

The following commands will help you remove the symbolic link from the public folder:

以下命令将帮助您从公共文件夹中删除符号链接:

cd public
rm storage

After removing the symbolic link change directory to the main folder using:

删除符号链接后,使用以下命令将目录更改为主文件夹:

cd ..

Now create the symbolic link with the following command:

现在使用以下命令创建符号链接:

php artisan storage:link

After running the command successfully, you should get the following message

成功运行命令后,您应该收到以下消息

The [public/storage] directory has been linked.

I hope this post helps you.

我希望这篇文章对你有帮助。

SYMLINK(): No Such File or Directory Laravel

SYMLINK(): 没有这样的文件或目录 Laravel

回答by Prakash Dahal

Follow these three steps:

请遵循以下三个步骤:

  1. Remove storage file from publicfolder.

    rm public/storage

  2. If storage folder is there in your root directory, remove public file inside app folder.

    rm storage/app/public

  3. Run link command

    php artisan storage:link

  1. 公共文件夹中删除存储文件。

    rm 公共/存储

  2. 如果根目录中有 storage 文件夹,请删除 app 文件夹中的公共文件。

    rm 存储/应用程序/公共

  3. 运行链接命令

    php工匠存储:链接

回答by Bashirpour

Make sure the APP_URLconfiguration in .envfile is set correctly. after that run following command line:

确保文件中的APP_URL配置.env设置正确。之后运行以下命令行:

php artisan config:cache
php artisan storage:link

回答by MirMSadeghi

I was using Vagrant and had the same problem. I removed to storage directory in public/storagebut couldn't resolve the problem when using the command php artisan storage:link.

我正在使用 Vagrant 并且遇到了同样的问题。我删除到存储目录中,public/storage但在使用命令时无法解决问题php artisan storage:link

Therefore I connected with ssh to my vagrant box and ran the command there. It worked, so if you are running Vagrant and have the same problem this might help.

因此,我使用 ssh 连接到我的流浪箱并在那里运行命令。它有效,所以如果你正在运行 Vagrant 并且遇到同样的问题,这可能会有所帮助。