phplaravelcpanel

Hosting Laravel on a cPanel server with public_html directory


I am trying to upload my Laravel project onto my web server, but my past two attempts have been unsuccessful. I believe I am not uploading the files to the right location.

This is my web server's structure:

/
- .composer
- .cpanel
- .htpasswds
- .softaculous
- access-logs
- etc
- mail
- perl5
- public_ftp
- public_html
- tmp
- www

Am I correct to think I need to upload ALL of my Laravel app's files into public_html?


Solution

  • No, but you have a couple of options:

    The easiest is to upload all the files you have into that directory you're in (i.e. the cPanel user home directory), and put the contents of public into public_html. That way your directory structure will be something like this (slightly messy but it works):

    /
        .composer/
        .cpanel/
        ...
        app/                 <- your laravel app directory
        etc/
        bootstrap/           <- your laravel bootstrap directory
        mail/
        public_html/         <- your laravel public directory
        vendor/
        artisan              <- your project's root files
    

    The other solution, if you don't like having all these files in that 'root' directory would be to put them in their own directory (maybe 'laravel') that's still in the root directory and then edit the paths to work correctly. You'll still need to put the contents of public in public_html, though, and edit the paths in public_html/index.php to correctly bootstrap the application. Your folder structure will be a lot tidier this way (though there could be some headaches with paths due to messing with the framework's designed structure more):

    /
        .composer/
        .cpanel/
        ...
        etc/
        laravel/      <- a directory containing all your project files except public
            app/
            bootstrap/
            vendor/
            artisan
        mail/
        public_html/  <- your laravel public directory