1

I'm currently getting a 403 error on the storage directory.
I have tried the correct file path for both a php artisan link and the regular symlink from command line The specific path is this one:

http://example.com/storage/app/public/category/zASySdXhEtXBaeWoz4KLJoIVLVxm3W6jRr6gHQhN.jpg 

This is linked to the storage directory: to here: example.com/public/storage/*

I created the symlink like so:

ln -s /var/www/vhosts/example.com/httpdocs/storage /var/www/vhosts/mydomain.com/httpdocs/public 

The above directory is for the symlink one but for php artisan link the url is slightly different.

the permissions set for storage before were executed running:

chmod -R 775 storage/ 

checking permissions I get this:

ls -la ./httpdocs 
drwxr--r-- 5 pacer psacln 46 Apr 8 2021 storage 

Everything else works except the storage directory. I've seen the other questions regarding 403 and have attempted those fixes but nothing is working. Any idea what I'm doing wrong?

2
  • (pacer psacln psaserv) which has ownership of the directory ? you can use chown to change permissions and make them sync first then try it again Commented Feb 25, 2022 at 20:05
  • I could be wrong but im not sure if your suppose to create a symlink to the entire storage folder vs a directory within the folder. For example in the past with laravel i have use the following command. "php artisan storage:link" Will create a link in public folder that is a symbolik link to the storage/app/public Commented Feb 25, 2022 at 20:06

4 Answers 4

1

The storage link points directly to the "app/public" folder. So the link address will look like this :

http://example.com/storage/category/zASySdXhEtXBaeWoz4KLJoIVLVxm3W6jRr6gHQhN.jpg 
Sign up to request clarification or add additional context in comments.

9 Comments

How are you arriving at this conclusion? The storage link doesn't have storage/category... it's /storage/app/public/category/ that's the directory with in the storage directory.
This is documented here: laravel.com/docs/9.x/filesystem#the-public-disk The symlink actually allows you to access the storage via the public folder which is the root for your app when being accessed via your domain.
@Johannes but the symlink was created via ssh like so: ln -s /var/www/vhosts/example.com/httpdocs/storage /var/www/vhosts/example.com/httpdocs/public this was explained in the question
@FabricioG Your files are in the "/storage/app/public/category/" path, but symlink is linked to the "app/public" path, so it does not have the "app/public" link address.
@Mohammad my bro the symlink is pointing to public so I'm using the full path.... if the link was broke then it would give a 404 NOT a 403 this produces a 403: storage/app/public/attribute_item/6XUd80jcd2A8lQl0xrlOAH4182nyJjJLi18CncDU.svg.
|
1

After a while spent on this the error was caused because I ran the php artisan storage:link and ln -s link with root. Therefore the link was unaccessible by my server for public consumption.

My solution was to switch to user:

su myUser 

Then run the php artisan storage:link

Comments

0

first : run commint

php artisan storage:link http://example.com/storage/category/zASySdXhEtXBaeWoz4KLJoIVLVxm3W6jRr6gHQhN.jpg 

Comments

0

If you are working under Docker, then the command

sail php artisan storage:unlink sail php artisan storage:link 

will solve the problem

It is important from which user you create the link

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.