Hi everyone,
I need to deploy Laravel 9 on a shared hosting, I know that there are many other threads on the forum about this subject but I can't find one that can help me with my actual Laravel version/hosting configuration.
The hosting doesn't have a /public_html folder that I can use as the standard /public like I saw in other threads and, because I'm using version 9, there is no server.php in the root to edit.
I could really use some help with this, thank you in advance for your support.
What folder does your server have for uploading files that can be opened in a browser (known as the document root)? Do you have any access to folders outside the document root?
If you don’t have access to anything outside the document root (which is not uncommon with shared hosting), don’t deploy Laravel apps to that hosting.
Hi @kokoshneta, thank you for your reply.
I can confirm that I don't have any access outside the document root, I can only add files/folders inside it.
Is there any workaround? I know that this type of deployment is discouraged but at the moment we can't use another hosting.
@dedadev Unfortunately, there is no way to safely deploy a Laravel app if you do not have access to any folders that are not viewable by the world. Things like .htaccess files can go some way towards plugging the worst of the security issues, but without folders outside the server software’s remit, you can’t plug them all.
Change your document root to <old_document_root>/public if possible.
If you can't change the document root, and you are running apache, create a ,htaccess where you rewrite any requests to the /public directory. You also need to make sure mod_rewrite is enabled. I have shared the .htaccess that I use in several threads here.