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_html
orpublic_html/your-app
). - Run the following command:
bash
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 thepublic
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:
bash
ln -s ../storage/app/public 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
andbootstrap/cache
folders, choose Change Permissions, and set them to775
or755
.
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.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:
bash
APP_URL=http://your-domain.com
Once these steps are complete, your storage link will be active on cPanel!