scraghty

Sep 20th, 2024 02:15 AM

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');

bobbyiliev

Sep 20th, 2024 04:08 AM

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

scraghty

Sep 20th, 2024 01:25 PM

I can’t change the name of public on the web server.

And on my version of cpanel I don’t think I can do a symlink.

Are these links broken when I zip, upload, unpack on the web server?

bobbyiliev

Sep 20th, 2024 01:37 PM

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:

Install Laravel with 1-Click on DigitalOcean

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.

scraghty

Sep 20th, 2024 02:30 PM

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?

bobbyiliev

Sep 22nd, 2024 11:43 AM

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

scraghty

Oct 14th, 2024 09:13 AM

@Oliver Jaxan

I see you replied to this post, but I cannot read the post. Bobbys last post of Sep 22nd is the last one I can see here.

bobbyiliev

Oct 14th, 2024 09:36 AM

Hey!

That was a spam user posting a spam answer. We've since deleted their answer and blocked the account.

- Bobby