简体   繁体   English

Laravel:符号链接():cPanel上没有这样的文件或目录

[英]Laravel : symlink(): No such file or directory on cPanel

Im trying todo php artisan storage:link on terminal in cPanel.我正在尝试php artisan storage:link It always show "symlink(): No such file or directory".它总是显示“符号链接():没有这样的文件或目录”。

I have also tried the method call Artisan on route: Route::get('/tes', function() { Artisan::call('storage:link'); });我还尝试了在路由上调用 Artisan 的方法: Route::get('/tes', function() { Artisan::call('storage:link'); }); . . Problem still same.问题还是一样。

Deleted folder storage on public_html and do php artisan storage:link , but still not working.删除public_html上的文件夹存储并执行php artisan storage:link ,但仍然无法正常工作。

Add function Register() on app->providers->AppServiceProvider.php:在app->providers->AppServiceProvider.php上添加function Register():

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

This is my index.php on folder public_html .这是我的index.php文件夹public_html

require __DIR__.'/../laravel/vendor/autoload.php';
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';

Folder Structure view: enter image description here文件夹结构视图:在此处输入图像描述

folder laravel view: enter image description here文件夹 laravel 查看:在此处输入图像描述

folder public_html view: enter image description here文件夹 public_html 视图:在此处输入图像描述

I managed to do this ln -s /path/to/target /path/to/shortcut , but i think its not perfect.我设法做到了ln -s /path/to/target /path/to/shortcut ,但我认为它并不完美。 because the link must display storage.因为链接必须显示存储。 If i success using php artisan storage:link , the link doesn't have to show storage.如果我成功使用php artisan storage:link ,则链接不必显示存储。 like example.com/storage/folderimage/abc.jpg and example.com/folderimage/abc.jpg比如 example.com/storage/folderimage/abc.jpg 和 example.com/folderimage/abc.jpg

According to the image: https://i.stack.imgur.com/OPukb.png I can't see the public folder inside laravel directory.根据图像: https://i.stack.imgur.com/OPukb.png我看不到 laravel 目录中的公用文件夹。

The following steps will fix the problem inChaAllah:以下步骤将解决ChaAllah中的问题:

  • Upload the public directory inside your laravel project.上传 laravel 项目中的公共目录。
  • Delete public/storage directory if exists.删除public/storage目录(如果存在)。
  • Run the following:运行以下命令:
     $ cd laravel
     $ php artisan storage:link

A symlink for storage is created inside laravel/public directory.laravel/public目录中创建了一个用于storage的符号链接。

  • Copy the contents of laravel/public/ directory into public_html .laravel/public/目录的内容复制到public_html中。
  • Update the path of laravel app inside public_html/index.phppublic_html/index.php中更新 laravel 应用程序的路径
  • Comment out the path.public binding inside AppServiceProvider.php .注释掉AppServiceProvider.php中的path.public绑定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM