1

I recently installed a Laravel app on an OVH shared hosting (pro so I have ssh access). This is my installation structure :

user
    app
       public
    www

Site access is under 'www' so I created a symbolic link there: ln -s /home/user/app/public /home/user/www/index.html

The symlink is working and pointing to the laravel public folder when I check in Filezilla. However when trying to access the site I am getting a 403 Forbidden You don't have permission to access this resource.

What am I doing wrong here ?

Arbiz
  • 172
  • 1
  • 5
  • 12
  • 1
    Try to give 755 permission to public folder – Vipin Farswan Jul 16 '20 at 13:27
  • It's already 755... – Arbiz Jul 16 '20 at 14:20
  • So how are you writing the files to `user/app`? With `scp`, `ftp` Or `git`? If git, are you using `sudo` anywhere (if at all possible in a shared host)? Are `app` and `www` owned by the same user/group? What user is running your web server process? Does this user have access to those files/directories? – dbf Jul 16 '20 at 20:01
  • I'm using git to upload to user/app, the owner is the ssh user I've been given. when I check the owner its is indeed the ssh user. Strangely when I do ls -l www I don"t see any owner at all..I don't think I can use sudo, I get "command not found" when I try... – Arbiz Jul 16 '20 at 20:26

3 Answers3

0

your symbolic link is problem... you are pointing to index.html instead of index.php

try this:

ln -s /home/user/app/public /home/user/www/index.php

and Create and put this .htaccess file in your laravel installation(root) folder.

 <IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
mohammadreza khalifeh
  • 1,510
  • 2
  • 18
  • 32
0

I couldn’t get this to work, it is not a laravel related problem by the way, I assume ovh doesn’t allow symlinks to a protected folder on shared servers. A shame really but I ended up installing laravel in the www folder and preventing access to root with an .htaccess

Arbiz
  • 172
  • 1
  • 5
  • 12
0

You can define a multisite with app/public as root folder. Also, I wouldn't have a link to a file like index.html, but either to a folder like ../app/public, e.g. to ensure __DIR__ works correctly in php. (By the way, Laravel does not have an index.html).

I had a similar issue on an OVH shared server: 403 forbidden, You don’t have permission to access this resource when accessing files in Laravel's public storage.

Tweaking .htaccess to allow from all or filesystem access control permissions to 777 rwxrwxrwx had no effect.

For me, the solution was to replace the absolute link /home/accountname/www/***/storage/app/public created by php artisan storage:link by the relative link ../storage/app/public

PaulH
  • 2,918
  • 2
  • 15
  • 31