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_html
or public_html/your-app
).
- Run the following command:
php artisan storage:link
If 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/public
folder and the public
folder.
- Check for Existing Symlink: Verify if the
public/storage
folder already exists. Delete it if incorrect.
- Create the Link: Open File Manager or use the Terminal and navigate to the
public
directory of your Laravel app. Run the following command:
ln -s ../storage/app/public storage
4. Set Correct Permissions
Ensure the storage
and bootstrap/cache
directories are writable:
- In cPanel, use File Manager to set permissions.
- Right-click on the
storage
and bootstrap/cache
folders, choose Change Permissions, and set them to 775
or 755
.
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:
http://your-domain.com/storage/test.jpg
Troubleshooting
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_URL
in your .env
file is correctly set to your domain:
APP_URL=http://your-domain.com
Once these steps are complete, your storage link will be active on cPanel!