DocumentRoot and httpd.conf

fk77388

Registered
Aug 22, 2013
3
1
3
cPanel Access Level
Website Owner
I have a server with multiple IP addresses. I am installing multiple domains to run from one code base, so I am defining the same document root. Each domain with it's own IP.

When I add the following (for each domain name/IP pair) in the pre_virtualhost_global.conf section in Service Configuration » Apache Configuration » Include Editor:
Code:
<VirtualHost 1.2.3.4:80>
    ServerName example.com
    ServerAlias *.example.com
    DocumentRoot /installdir/ofonecodebase
</VirtualHost>
The result in httpd.conf virtual hosts section of DocumentRoot comes out /pathto/defineddocroot/username/public_html
How can I force generating httpd.conf with the DocumentRoot I defined - without username ...

There is no one document that lists file names and sequence used in generating httpd.conf and some threads say that cPanel preferred method is to use the include editor.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,205
363
Hello :)

You can modify the document root for a domain name by editing the "documentroot" entry in the appropriate cPanel user data file:

Code:
/var/cpanel/userdata/$username/$domain.com
Then, rebuild the Apache configuration file via:

Code:
/scripts/rebuildhttpdconf
Thank you.
 

fk77388

Registered
Aug 22, 2013
3
1
3
cPanel Access Level
Website Owner
Re: DocumentRoot and htttpd.conf [Resolved]

Hello :)

You can modify the document root for a domain name by editing the "documentroot" entry in the appropriate cPanel user data file:

Code:
/var/cpanel/userdata/$username/$domain.com

Thank you Michael, it worked. :)
Just in case someone else run into same issues, I am documenting procedure I followed below.

After making changes to files above. I ran into another problem with php's open_basedir in httpd.conf, it was pointing to the old user's home directory for each domain respectively. To resolve:

1- copy /var/cpanel/templates/apache2_4/vhost.default to /var/cpanel/templates/apache2_4/vhost.local
note: your directory may say apache2_2 or apache2, I am running ver. 2.4

2- edit vhost.local, the section that begins with:
Code:
[% IF phpopenbasedirprotect_enabled && vhost.phpopenbasedirprotect && ( supported.libphp4 || supported.libphp5 ) -%]
and ending with
Code:
[%- END %]
Replace every instance of vhost.homedir to vhost.documentroot

3- save file and run the following:
Code:
/usr/local/cpanel/bin/apache_conf_distiller --update
/usr/local/cpanel/bin/build_apache_conf
service httpd restart
******************************************************************************
Run multiple domains from one code base Wordpress / Drupal / Joomla.

Configure vhosts file and httpd.conf to run multiple domains from same code base Wordpress / Drupal / Joomla
 
Last edited:
  • Like
Reactions: MaxFein