PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, February 14, 2022

[FIXED] Laravel smlink not found

 February 14, 2022     composer-php, laravel, php, shared-hosting     No comments   

Issue

I upload my laravel website to shared hosting ". Every things work except i am not able to retrieve images stored in the storage/public folder. I ran

 "php artisan storage:link" 

but it says not found. I also tried

rm storage

but the getthe message rm: cannot remove. Is directory php artisan storage:link output from ssh command


Solution

Note, I'm not addressing the original answer because it doesn't sound like it can be done. This is an alternate solution.

Solution

In your config/filesystems.php file, you'll see the following code (or something similar).

    'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
            'endpoint' => env('AWS_ENDPOINT'),
        ],

    ],

To link your public disk to a public directory without using OS symlinks, change the disks['public']['path'] to the public path of your choosing. For example,

    'disks' => [
        /** -- skipped code **/
        'public' => [
            'driver' => 'local',
            'root' => __DIR__ . '../public/images/`,
            'url' => env('APP_URL').'/images',
            'visibility' => 'public',
        ],
        /** -- skipped code **/
    ],

Another Solution

You can totally use the S3 storage as well. That will connect you with an AWS bucket that you can use.

Personal Anecdote

Shared hosting can be tricky with Laravel. I would transition away as soon as I could. I use Laravel Forge to deploy servers and Digital Ocean or AWS for hosting.



Answered By - Jacob
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing