Configure DocumentRoot over the Web UI

I do believe this question/feature request was already asked in the VestaCP forums a while ago, but I couldn’t find anything related here: some PHP frameworks, such as Laravel, do rely on custom root directories. For example, Laravel has a project structure like:

- app/
-- (most PHP sources are here...)
- config/
- public/
-- (static assets, .htaccess and the index.php is here...)
- ...

In the case of Laravel, they expect you to set the Apache2 option DocumentRoot to the public/ subdirectory, which is currently not possible with HestiaCP (and never was possible with VestaCP). Manually overriding the Apache2 configs doesn’t work either, because they are autogenerated by the panel. The only option right now is to place another .htaccess file in projects root and play a bit with RewriteRules. Thought, that works, I really would prefer to just have the option to override the DocumentRoot and would like to place a feature request here for a new field in the server settings to support something like setting an arbitrary subdirectory for HesitaCP instead of fixing it to the public_html/ directory of each domain.

It is currently possible by copying a template file and modifying it see:

https://docs.hestiacp.com/admin_docs/server_management.html#how-do-web-templates-work

How ever I do agree this can be supported from with in the panel and we are working on it. Will be in next feature release probally.

See:

Inputs:

$user = User name where domain you wish to change resides
$domain = Source domain which you want to change to a different document root
$target_domain = Target domain
$target_directory = (Optional) Specify a directory inside of the target domain’s public_html folder.

Examples:

  • v-change-web-domain-docroot admin test.tld otherdomain.tld = Sets test.tld to use /home/admin/web/otherdomain.tld/public_html/ as its document root.
  • v-change-web-domain-docroot admin test.tld otherdomain.tld somefolder = Sets test.tld to use /home/admin/web/otherdomain.tld/public_html/somefolder/ as its document root.
  • v-change-web-domain-docroot admin test.tld test.tld somefolder = Sets test.tld to use /home/admin/web/test.tld/public_html/somefolder/ as its document root.
  • v-change-web-domain-docroot admin test.tld default = Restores the default document root value for test.tld (/home/admin/web/test.tld/public_html/ .

To answer your question as to whether the document root directory will be created, the command expects the value passed to $target_directory to exist under /home/$user/web/$target_domain/public_html/ and will throw an error if it does not exist.

1 Like

Oh wow, nice. Thanks for letting me know, I must have missed that one.

It is currently not available it will be in a future release.

1 Like

Folder? Directory, please. :stuck_out_tongue:

1 Like