1
votes

Got some issues on production. In details, I have deployed Laravel project on shared hosting cPanel, I have kept my project in root folder and Laravel`s public folder kept inside public_html, and when I run PHP artisan storage: link it creates a symlink of storage folder in myfolder/public but I want it to go inside public_html

How can I do that?

2
"I have kept my project in root folder and Laravel`s public folder kept inside public_html" what did you do actually ? did u just copy the public directory of your laravel app into your public_html ? or creating symlink between your laravel/public and public_htmlfahim152
copy public folder content into public_htmlDEEPAK
is this working ? I mean can u run your app by hitting url ?fahim152
yes it is workingDEEPAK

2 Answers

3
votes

You can create custom symlink via cli !

cd to your laravel project directory and run the following command

ln -sr storage ../public_html/storage 

This will create a symbolic link of your storage folder inside your public_html folder.

1
votes

A solution could be to make a custom artisan command, something like storage_custom:link and copy the contents of the original storage:link comamnd and just change the paths as you want them to be. Here you can see the original storage:link command in Laravel.

class StorageLinkCommand extends Command
{
    /**
     * The console command signature.
     *
     * @var string
     */
    protected $signature = 'storage:link';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Create a symbolic link from "public/storage" to "storage/app/public"';

    /**
     * Execute the console command.
     *
     * @return void
     */
    public function handle()
    {
        if (file_exists(public_path('storage'))) {
            return $this->error('The "public/storage" directory already exists.');
        }

        $this->laravel->make('files')->link(
            storage_path('app/public'), public_path('storage')
        );

        $this->info('The [public/storage] directory has been linked.');
    }
}