#403 Forbidden on New Laravel app
36 messages · Page 1 of 1 (latest)
any print, can you give more details?
@hasty sand The files/folders need to be readable by the webserver, regarding permissions.
..possibly writable as well, depending on what your code wants to do.
My .htaccess only had ```<IfModule mime_module>
AddHandler application/x-httpd-ea-php82 .php .php8 .phtml
</IfModule>
php -- END```
So I just added ```Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]```
And now I get "File not found."
I'm just trying to hit the home-page...
Verify the site config, both php and apache need the right folders.
Tutorials on this might be handy for this, so that you're not missing any steps.
I'm running Laravel 11 and just trying to hit my home page "/"
have you actually pointed the document root to be in your apps public folder?
My httpd.conf has this:
ServerAlias www.preview.xxx.com
DocumentRoot /home/xxx/public_html/preview/public/
ServerAdmin [email protected]
UseCanonicalName Off
<Directory /home/xxx/public_html/preview/public/>
AllowOverride All
Require all granted
Allow from all
</Directory>```
That doesn't tell us whether those folders are real and exist or not.
/home/xxx/public_html/preview/public/ is a valid folder. I've set all the files in there to 644 and folders to 755. If I go to preview.xxx.com/.env I'm able to read the file a plain text (bad! but tell us something)
What happens if you try to load index.php?
Your doc_root should be the public directory... your laravel app base directory should NEVER be available to the public
Right, .env is in the folder one step above public.
right but if you can load .env in the browser, its misconfigured
Not sure what others do, but, i like to keep my laravel apps in /home/user/production/ and then symlink /home/user/public_html/ to /home/user/production/public/
that way the app itself is never in the doc_root
I'm using a CPANEL managed server...any tips on having it honor the DocumentRoot in apache?
You can do exactly as a described on cPanel
If you dont have shell access to your account, you MAY be able to symlink inside the File Manager
@hasty sand What folders are there inside the public folder? Is there an app folder?
Just make sure to move the cPanel default .htaccess over to your public as EasyApache and PHP Manager will maintain your PHP version mod inside it
I think I got it.. in CPANEL, I found an option to change the Document root for a domain. I changed it and now the front-page loads!
There ya go!
Can you please advise what permissions I need to set to secure my folders? Online, I'm finding tutorials that do 777 for everything which I know is wrong
Also, am I supposed to put /public and /resources in my .gitignore file?
the default .gitignore that Laravel ships with should be sufficient for most things
unless you are adding other files to your project (vscode workspace, postman workspace, notes, etc) or others that you don't want in VC, it should be fine
For example, on my server after running Vite npm run build, I am seeing public/build/assets/app-UqRVr5q0.css Should I add public/build to my .gitignore? It isn't in the default
I'm also seeing tons of changed files in /public/dist, /public/fonts, /resources/plugins etc.
Some folks would say not to put built/compiled assets into VC, some don't care... Dependening on project size, if you're committing both, you're doubling up and when you deploy, you have to build anyway, so, why commit the built