Are you sure the storage:link folder is inside public/www and not inside public?
I have no images after symlink() connected (storage:link)
www/index.php
require __DIR__.'/../domain/vendor/autoload.php';
$app = require_once __DIR__.'/../domain/bootstrap/app.php';
$app->bind('path.public', function() {
return __DIR__;
});
domain/server.php
if ($uri !== '/' && file_exists(__DIR__.'/../www/'.$uri)) {
return false;
}
require_once __DIR__.'/../www/index.php';
www/.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
www dir https://i.imgur.com/jCN68qy.png
Hi, @laracoft . content from public is in www(public_html), other files from laravel is next to "www" folder named for example "domain". symlink (storage:link) generate folder in www(www/storage) but this storage really is in domain/storage/app/public
https://i.imgur.com/eFxI7E0.png
when i check image url: "Forbidden You don't have permission to access this resource."
@hekmatyar can't follow your description
domain
├── app
├── public
│ ├── storage <-- is it here? (X)
│ └── www
│ └── storage <-- or is it here? (Y)
├── vendor
...
└── storage
Why are you messing around with Laravel's folder structure with domain and www?
(Z) Look at picture.. is up. i don't messing with anything
domain-> laravel, www->public_html
domain(rest of laravel)
├── app
├── bootstrap
├── config
├── db
├── hooks
├── resources
├── routes
├── storage
├── teste
├── vendor
...
www(public_btml <- here is contect from public.)
├── storage
├── bootstrap
├── src
├── index.php
now its clear for you..?
You need to create symlink manually, run this command from www folder
ln -s ../domain/storage/app/public storage
And don't forget to remove previous symlink to storage.
I have never needed symlink. I just serve secured (private) images with a script.
But I agree if your folder structure gets set up correctly it should work.
@michaloravec how to use this command?
i was doing something like this
-
delete storage (from public_html)
-
clear
voyager::compass.commands.command_output:
Compiled views cleared!
Application cache cleared!
Route cache cleared!
Configuration cache cleared!
Compiled services and packages files removed!
Caches cleared successfully!
- storage:link
voyager::compass.commands.command_output:
The [/home/accc/www/storage] link has been connected to [/home/accc/domain/storage/app/public].
The links have been created.
???????????????????????
@hekmatyar have some patience, everyone has to sleep.
domain
├── app
├── config
├── resources
├── routes
├── ............. <- X. where is your `public` folder???
├── storage
├── teste
├── vendor
...
www <- Y. why did you create this, is it inside or outside `domain`?
├── storage
├── bootstrap
├── src <- Z. why does this `src` exist?
├── index.php
Laravel
├── app
├── public
│ └── storage
├── vendor
...
└── storage
Basically your folder structure is not according to Laravel. So, your images will never load. A Laravel folder structure has to look like what I show above.
ehh, everyone says differently.. but ok i made structure like you say..
Laravel
├── app
├── public
│ └── storage
├── vendor
...
└── storage
The [/home/domain/www/public/storage] link has been connected to [/home/domain/www/storage/app/public].
The links have been created.
and no images...
@hekmatyar so your Laravel root folder is www?
yes, i said about it couple post ago. folder: www = public_html
This is the Laravel standard.
www <- Laravel root folder
├── app
├── public <- http://localhost/
│ └── storage <- http://localhost/storage links to <──┐
├── vendor │
... │
└── storage │
└── app │
└── public <───────────────────────────────────────┘
Since www is your Laravel root domain, please leave domain out of the picture. There is also no such thing as public_html in Laravel. These terms are very confusing.
You are free to link www/public/storage to any other folder. But please understand where you are linking to and that those folders have the necessary permissions. Without knowledge of all these, you are better off just sticking to the Laravel standard structure.
Here you go :D https://i.imgur.com/lSoy9eI.png
btw. its sharedhost from ovh im not doing this in localhost
jlrdw and snapey say to made this structure and other tuts. im trying to understand this all but everyone says differently.
@hekmatyar localhost is just an example to explain where your HTTP root directory should point to.
@hekmatyar I'm not sure how to make sense of your screenshot. What do you want to show? Do you have www/public/storage and is it symlinked to www/storage/app/public?
ffs..
The [/home/domain/www/public/storage] link has been connected to [/home/domain/www/storage/app/public].
The links have been created.
YES.
Put an image file in /home/domain/www/storage/app/public/image.png and load http://localhost/storage/image.png.
Forbidden You don't have permission to access this resource.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
Put the same image in /home/domain/www/public/image.png and load http://localhost/image.png. What happens?
it works
/home/domain/www/storage/app/public/ seems to have permission issues. Can you restore your /home/domain/www/public/.htaccess to original?
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
restored. nothing changed, still missing images
but. i have 1 more htaccess for root folder (www)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ public/
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ public/index.php [L]
</IfModule>
Don't say missing images, it is misleading, the error you have is 403 Forbidden You don't have permission to access this resource.
Where is the other .htaccess, please provide full path, otherwise it is left to my imagination and does not help in solving your problem.
ok, this file /home/domain/www/.htaccess can be deleted. It should not even exist in the first place.
You might have a permissions issue, set /home/domain/www/storage/app/public/ to 0755
chmod 0755 /home/domain/www/storage/app/public/
Put an image file in /home/domain/www/storage/app/public/image.png and load http://localhost/storage/image.png
if i delete it i will lose site view and i will get files list from serve
Please or to participate in this conversation.