public_html
I cannot for the life of me get the framework to recognize public_html.
I am using vite. And my webserver uses public_html
Laravel uses public directory, and I need to public_path to public_html instead.
I have messed around in filesystem, bootstrap, appservicesprovider and others with no luck.
Bobby!!! What am I missing?
EDIT FINALLY GOT SOMETHING THAT WORKS BUT IS IT RIGHT? bootstrap/app.php
// .... ->create() ->usePublicPath(dirname(DIR).'/public_html');
Hi,
The best approach would be to adjust your web server configuration to use the public
directory instead of public_html
. Laravel is built around the public
directory structure, and changing it can introduce complications.
Alternatively, you can create a symbolic link (symlink) from public_html
to public
, which is a straightforward way to work with your web server's setup while maintaining Laravel's directory structure.
To create a symlink, run the following command in your project directory:
ln -s /path/to/the/larave/public /path/to/your/pubic/public_html
This way, your server can still point to public_html
, while Laravel continues to function as expected.
- Bobby
Hi,
An option here is to add your domain name as an addon domain name on cPanel. That way you will be able to change the document root so that it matches the Laravel public directory.
Another option is to just use a normal serer without cPanel:
Not sure if I get this question here:
Are these links broken when I zip, upload, unpack on the web server?
Unzipping a zip file should not break the links in any way.
Question was referencing symlink.
Storage is already symlinked in my local but after moving everything to the web server that broke.
I didn’t think that symlink was able to carry through after that observation. And I don’t have a way to relink that with my current low level knowledge level.
What is my solution doing in bootstrap? Is there risk borne from this method?
Hey!
Ah yes, thanks for that clarification! Indeed on your local machine the storage link might be totally different than the one on the server.
What you could do on your server is to just re-create the symlink:
# Access the Laravel directory on your server:
cd /path/to/your/laravel/on-the-server/
# Remove the broken link:
unlink public/storage
# Create a new link:
php artisan storage:link
- Bobby
Hey!
That was a spam user posting a spam answer. We've since deleted their answer and blocked the account.
- Bobby