apache - How to customize vhost file for a WHM-CPanel host? -
i want change document root particular host.
currently setting host :
<virtualhost 123.164.132.142:80> servername abc.com serveralias mail.abc.com www.abc.com documentroot /home/abc/public_html serveradmin webmaster@abc.com usecanonicalname off customlog /usr/local/apache/domlogs/abc.com combined <ifmodule log_config_module> <ifmodule logio_module> customlog /usr/local/apache/domlogs/abc.com-bytes_log "%{%s}t %i .\n%{%s}t %o ." </ifmodule> </ifmodule> ## user abc # needed cpanel::apacheconf <ifmodule userdir_module> <ifmodule !mpm_itk.c> <ifmodule !ruid2_module> userdir enabled </ifmodule> </ifmodule> </ifmodule> # enable backwards compatible server side include expression parser apache versions >= 2.4. # selectively use newer apache 2.4 expression parser, disable ssilegacyexprparser in # user's .htaccess file. more information, please read: # http://httpd.apache.org/docs/2.4/mod/mod_include.html#ssilegacyexprparser <ifmodule include_module> <directory "/home/abc/public_html"> ssilegacyexprparser on </directory> </ifmodule> <ifmodule suphp_module> suphp_usergroup abc abc </ifmodule> <ifmodule !mod_disable_suexec.c> <ifmodule !mod_ruid2.c> suexecusergroup abc abc </ifmodule> </ifmodule> <ifmodule ruid2_module> rmode config ruidgid abc abc </ifmodule> <ifmodule mpm_itk.c> # more information on mpm itk, please read: # http://mpm-itk.sesse.net/ assignuserid abc abc </ifmodule> <ifmodule alias_module> scriptalias /cgi-bin/ /home/abc/public_html/cgi-bin/ </ifmodule> include "/usr/local/apache/conf/userdata/std/2_4/abc/abc.com/*.conf" </virtualhost>
i tried create conf file in /usr/local/apache/conf/userdata/std/2_4/abc/abc.com/
change document root .../public_html/public
run /scripts/ensure_vhost_includes --all-users
rebuild httpd.conf , restart apache. however, don't think it's taking effect because files in public_html
still accessable world.
what's correct way customize settings host?
to create custom template affects how cpanel & whm builds entries single virtual host, you'll have perform following steps:
create copy of 1 or more of following files:
apache 2.2 ssl — /var/cpanel/templates/apache2_2/ssl_vhost.default apache 2.4 ssl — /var/cpanel/templates/apache2_4/ssl_vhost.default apache 2.2 without ssl — /var/cpanel/templates/apache2_2/vhost.default apache 2.4 without ssl — /var/cpanel/templates/apache2_4/vhost.default
rename new copy of file 1 of following filenames:
vhost.local (use filename if copied vhost.default file)
ssl_vhost.local (use filename if copied ssl_vhost.default file)
edit new file make changes virtual host configuration. move new file other directory (let's /opt example). let's have new template /opt/new-vhost-template
use following script add necessary information data structure:
perl -myaml::syck -e \ 'my $hr = yaml::syck::loadfile($argv[0]);$hr->{$argv[1]} = $argv[2];yaml::syck::dumpfile($argv[0],$hr);' \ /var/cpanel/userdata/$username/$domainname custom_vhost_template_ap2 /opt/new-vhost-template
that should trick!
please keep in mind above example applies specific vhost cpanel user/account , not apply vhosts on server.
Comments
Post a Comment