1
votes

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

1
This can be a number of things. Because you're using shared hosting, I would suspect a permissions issue. You can bypass this issue by linking your public storage to a public folder. That way you don't need to use a symlink.Jacob
I suspect its a permission issue as well. How could i link it?Adrian
chown -R www-data:www-data /var/www/project/ give permission to storageNazmus Sakib
How did you "upload" your website? Have you checked whether the symlinks point to the proper directories? And how is this related to Composer?Nico Haase

1 Answers

0
votes

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.