Change apache directive for almost each Hestia domains

Well, I think I misasked my question. Let’s forget Wordpress and its specificities.

I just would like to know how to change the Apache DocumentRoot directive for each of the domains installed in Hestia > apache2.conf

"/home/domain.com/conf/web/domain.com"

please. Thank you

Create a new template

cp default.tpl custom_doc_root.tpl

Modify custom_doc_root.tpl
DocumentRoot %docroot%

to the docroot you want
repeat for stpl and the nginx config is needed

Loads the correct templates via admin

1 Like

@eris, sorry, but I still don’t understand sorry, do I replace %docroot% by %mydomain.com% ? and %sdocroot% by %smydomain.com% ?

thanks

If you want to forward al the domains to domainy.com on user test the docroot will be

/home/test/web/domainy.com/public_html

If you are using a different site for https it will become

/home/test/web/domainy.com/spublic_html otherwise /home/test/web/domainy.com/public_html will work fine

1 Like

My question was after this step > “cp default.tpl custom_doc_root.tpl” do I replace the term between %xxxx% by a domain or a path ?

DocumentRoot %docroot% becomes

DocumentRoot /home/ test /web/ http://domainy.com /public_html

This is how it is implemented in the future 1.3.0 release

Ok, did it > modified custom.domain.tpl ant stpl but don’t see choice in admin panel, just “default” under apache drop down menu :no_mouth:

Put it in /apache2/php-fpm folder

Error: apache2 restart failed > inside custom.tpl I change these lines :

DocumentRoot /home/customdomain/web/customdomain/public_html

and

<Directory /home/customdomain/web/customdomain/public_html>

Check sytemctl status apache2 what is wrong…

seems like error syntax… :

● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2020-09-05 21:01:44 UTC; 23min ago
     Docs: https://httpd.apache.org/docs/2.4/
  Process: 6446 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)

Sep 05 21:01:44 srv-b.democrasite.com systemd[1]: Starting The Apache HTTP Server...
Sep 05 21:01:44 srv-b.democrasite.com apachectl[6446]: AH00526: Syntax error on line 25 of /etc/apache2/conf.d/domains/opaz-ateliers.com.conf:
Sep 05 21:01:44 srv-b.democrasite.com apachectl[6446]: Invalid command 'php_admin_value', perhaps misspelled or defined by a module not included in the server configuration

You will need to use the file from /apache2/php-fpm folder

as the /apache2/ contains the template for non php-fpm / “modphp” sites and they won’t work on Apache2 in event mode. (Default)

? sorry, I don’t understand

You will need to use the templates from the correct folder

/usr/local/hestia/data/templates/web/apache2

Will work only for the “non php-fpm” setup still running in Apache2 “Prefork” mode

We have switched for preformance reasons to “Event mode” for Apache2 + PHP-fpm and there for the files can be found in

/usr/local/hestia/data/templates/web/apache2/php-fpm 

Those template files can’t be switched between them

Ok, I’m there /usr/local/hestia/data/templates/web/apache2/php-fpm

So if I understand well, my last chance is try to modiy document root directives directly in default.tpl and default.stpl ?

You probably picked the wrong template and template folder then…

Ps: oh sorry, somehow saw the comments above too late :man_facepalming:

tl;dr; what @eris said… :sweat_smile:

still no redirection to main site. I went :

/usr/local/hestia/data/templates/web/apache2/php-fpm

modified : default.tpl and default.stpl

directives :

<VirtualHost %ip%:%web_port%>

    ServerName %domain_idn%
    %alias_string%
    ServerAdmin %email%
  #  DocumentRoot %docroot%
    DocumentRoot /home/democrasite_admin/web/democrasite.com/public_html

    ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/
    Alias /vstats/ %home%/%user%/web/%domain%/stats/
    Alias /error/ %home%/%user%/web/%domain%/document_errors/
    #SuexecUserGroup %user% %group%
    CustomLog /var/log/%web_system%/domains/%domain%.bytes bytes
    CustomLog /var/log/%web_system%/domains/%domain%.log combined
    ErrorLog /var/log/%web_system%/domains/%domain%.error.log

    IncludeOptional %home%/%user%/conf/web/%domain%/apache2.forcessl.conf*

    <Directory %home%/%user%/web/%domain%/stats>
        AllowOverride All
    </Directory>
    #<Directory %sdocroot%>
    <Directory /home/democrasite_admin/web/democrasite.com/public_html>

        AllowOverride All
        Options +Includes -Indexes +ExecCGI
    </Directory>

    <FilesMatch \.php$>
        SetHandler "proxy:%backend_lsnr%|fcgi://localhost"
    </FilesMatch>
    SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0

    IncludeOptional %home%/%user%/conf/web/%domain%/%web_system%.conf_*

</VirtualHost>

but it doesn’t want to redirect, I always arrive on the default page of the Hestia User/domain = opaz-ateleirs.com that I want to point to the MainWordpress :

/home/opaz-ateliers.com/web/opaz-ateliers.com/public_html

We’re working on it!

This site is currently under construction.

Please check back soon.

I think the redirection is not working or I have a syntax error somewhere.

rather confusing for me, what is the right file to modify then? :no_mouth:

Modifying templates depends on what you’ve installed and is well documentated here: https://docs.hestiacp.com/admin_docs/server_management.html#how-do-web-templates-work

I made this here:
/usr/local/hestia/data/templates/web/apache2/php-fpm :

cp original.tpl new.tpl
cp original.stpl new.stpl

but maybe I didn’t understand what eris told me:

“/usr/local/hestia/data/templates/web/apache2/php-fpm
Those template files can’t be switched between them”.

I understood that then we couldn’t select a different one than “default” in the “apache” menu in the Hestia dashboard?
can I select in the dashboard : new.stpl or let selection on original.tpl ?

in the documentation there is no explanation about changing an apache2 directive to change the DocumentRoot > destination path

What I need to achieve when I use a classic LAMP is to modify the Vhost of a Domain to tell it that its DocumentRoot is the DocumentRoot of another Domain/

On my current VPS my main domain is here:

/var/www/democrasite2017

For a second domain that must point to this location, in its Vhost file the Apache directives are :

/etc/apache2/sites-enabled

DocumentRoot /var/www/democrasite2017
+--------------------------------------+
<VirtualHost *:80>
 </Directory>
        <Directory /var/www/democrasite2017>
                FollowSymLinks options
                AllowOverride All
        </Directory>

on the other hand at the end of the file there is also :

RewriteEngine on
RewriteCond %{SERVER_NAME} =www.opaz-ateliers.com [OR]
RewriteCond %{SERVER_NAME} =opaz-ateliers.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} END,NE,R=permanent] [END,NE,R=permanent]
</VirtualHost>

Thanks for your help :slight_smile: