Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

onieyanihh's avatar

Help with Laravel 9 Hosting on Live server

Hi. I installed laravel 9 in my cpanel using cpanel terminal. but when i try to access it in my url website, i only getting Index of / then below is all the laravel 9 files i installed.

Please see the link below for the screenshot. Thank you!

https://prnt.sc/fYTgnBFNQ5bn

0 likes
8 replies
LaryAI's avatar
Level 58

It seems like the public directory is not being served as the document root. You need to set the document root to the public directory of your Laravel application.

To do this, follow these steps:

  1. Login to your cPanel account and navigate to the "Domains" section.
  2. Click on "Subdomains" and create a subdomain with the name of your Laravel application (e.g. mylaravelapp.example.com).
  3. Set the document root of the subdomain to the public directory of your Laravel application (e.g. /home/username/public_html/mylaravelapp/public).
  4. Save the changes and wait for them to take effect.

Once the changes have taken effect, you should be able to access your Laravel application by visiting the subdomain you created (e.g. mylaravelapp.example.com).

If you still face any issues, make sure that your server meets the requirements for running Laravel 9 and that you have installed all the necessary dependencies. You can also check the error logs for any clues on what might be causing the issue.

// Example of setting the document root in cPanel
// Replace "username" and "mylaravelapp" with your own values
DocumentRoot /home/username/public_html/mylaravelapp/public
onieyanihh's avatar

I figured it out. I already hosted my project thank you! My problem is my @vite not working in live server. and in localhost, my @vite just gonna work if i open terminal and then type npm run dev but if i dont do that, its not gonna work.

onieyanihh's avatar

this is my .htaccess config

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteRule ^(.*)$ public/ [L]
</IfModule>

i have that htaccess to remove the "/public" in my url for my website to work

OussamaMater's avatar

@onieyanihh I think this is what you are looking for

In shared hosting the public directory is public_html, so you need to configure Laravel to use public_html instead of public.

In your AppServiceProvider.php

public function register()
{
  $this->app->bind('path.public', function() {
    return base_path().'/public_html';
  });
}

app()->usePublicPath(base_path() . '/public_html');

Please or to participate in this conversation.