Deploy laravel 10 to public_html | as a root

I need to serve the /public folder of my laravel 10 app from the /root.
There are few ways to do that in previous versions of laravel, but they won’t work in laravel 10.
/lara contains all core laravel-files plus the entry point index.php which must be served from the root: www.example.com/index.php (not as www.example.com/lara/public/index.php)

Assuming I’ve installed hCP with the default Apache + Nginx, where do I find the Apache virtual-host file so I can configure the root of my website as above?

The quick-app laravel 10 installs the latest version (laravel 11) and it doesn’t work because of the folder structure that I’m discussing here.

  • hCP 1.8.11
  • Apache + Ninx
  • Php 8.2
  • laravel 10

Option #1

/public_html
  /lara
     /core
     /public/index.php    // only a simple html-homepage works with this structure 
                                     // but not other pages - laravel must be served from the /root.

Option #2
I tried the structure below by updating the links in index.php - but I’m getting error 500. Laravel is unable to initialize the application with this folder structure:

/core
/public_html
  index.php    // can't make it work this way

Option #3
I also tried to delete /public_html and replace it with a symlink pointing to /public: still error 500

For example, when I enter this url I want /public/index.php to be served:

www. example.com/home

    <VirtualHost *:80>  
    ServerName home
    ServerAlias home
    DocumentRoot "${INSTALL_DIR}/www/example/lara/public"   
    <Directory "${INSTALL_DIR}/www/example/lara/public/">     
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
    </VirtualHost> 

Please help, many thanks

You can modify the document root for your domain. Edit web domain -> Advanced options -> Custom document root and there add lara/public/ as Directory

imagen

1 Like

Thank you, it worked.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.