laravel storage link in shared host
Laravel

Laravel symbolic link in shared host

It’s not easy to deploy laravel applications in shared hosts. one of the problems after deploying laravel applications in shared hosts is make a symbolic link.

Laravel has a public disk to store the application uploaded files.

The public disk included in your application’s filesystems configuration file is intended for files that are going to be publicly accessible. By default, the public disk uses the local driver and stores its files in storage/app/public.

To make these files accessible from the web, you should create a symbolic link from public/storage to storage/app/public. 

For making the symbolic link you should run this command in the terminal.

php artisan storage:link

We don’t have access to the terminal in shared hosts but we have something called Cron Job.

With cron job, we can run some code per minute, daily, weekly, and …

We should set a cron job in Cpanel to create a symbolic link.

Cron Job in Cpanel

Open cron job in Cpanel and set a cron job per minute and use this command.

ln -s /home/YOUR_HOST_NAME/YOUR_APP_DIRECTORY/storage/app/public /home/YOUR_HOST_NAME/YOUR_PUBLIC_DRIECTORY/storage

Replace YOUR_HOST_NAME, YOUR_APP_DIRECTORY, and YOUR_PUBLIC_DRIECTORY with your own.

https://github.com/mahdisharifi-dev/laravel-symlink-in-shared-hosts

Leave a Reply

Your email address will not be published. Required fields are marked *