Appearance
Enable Storage Link in Laravel on cPanel
1. Access Your cPanel
Log in to your cPanel account provided by your hosting service.
2. Open Terminal (If Available)
If your cPanel has a Terminal option, use it to execute commands directly:
- Navigate to the root directory of your Laravel application (e.g.,
public_htmlorpublic_html/your-app). - Run the following command:
bash
php artisan storage:linkIf the Terminal is not available, proceed to the next step.
3. Create the Storage Link Manually (File Manager Method)
If you cannot use the terminal, follow these steps to create the symbolic link manually via cPanel's File Manager:
- Go to File Manager in cPanel.
- Locate your Laravel project directory.
- Find the
storage/app/publicfolder and thepublicfolder. - Check for Existing Symlink: Verify if the
public/storagefolder already exists. Delete it if incorrect. - Create the Link: Open File Manager or use the Terminal and navigate to the
publicdirectory of your Laravel app. Run the following command:
bash
ln -s ../storage/app/public public/storage4. Set Correct Permissions
Ensure the storage and bootstrap/cache directories are writable:
- In cPanel, use File Manager to set permissions.
- Right-click on the
storageandbootstrap/cachefolders, choose Change Permissions, and set them to775or755.
5. Verify the Link
After creating the link, the public/storage directory should point to storage/app/public.
6. Test File Access
Upload a file (e.g., test.jpg) to storage/app/public via File Manager or your Laravel application. Test the link by accessing the file in your browser:
bash
http://your-domain.com/storage/test.jpgTroubleshooting
- Symbolic Link Not Allowed by Hosting: If your hosting provider doesn’t allow symbolic links, contact them to enable this option or use a shared hosting-compatible solution.
- Storage Not Accessible: Ensure the
APP_URLin your.envfile is correctly set to your domain:
bash
APP_URL=http://your-domain.comOnce these steps are complete, your storage link will be active on cPanel!
