16.04 - Userdir with Virtual Host (Apache2) - Ask Ubuntu
using ubuntu 16.04 , apache 2.4.7 want make 2 different types of userdir.
- the data in
/home/user/public_html/
, accessed via www.sample.com/~user/. (www2.sample.com/~user/ should not work.) - the data in
/home/user/public_html2/
, accessed via www2.sample.com/~user/. (www.sample.com/~user/ should not work.)
i finished making 2 virtual hosts using /etc/apache2/sites-availabile/000-default.conf, , tried modify mods-available/userdir.conf. easy make either public_html or public_html2 accessible, failed make both accessible different host names. teach me how this?
i cannot write code is, 000-default.conf , userdir.conf these:
000-default.conf
<virtualhost *:80> serveradmin admin@sample.com documentroot /var/www/html/www servername www.sample.com errorlog ${apache_log_dir}/error.log customlog ${apache_log_dir}/access.log combined </irtualhost> <virtualhost *:80> serveradmin admin@sample.com documentroot /var/www/html/www2 servername www2.sample.com errorlog ${apache_log_dir}/error.log customlog ${apache_log_dir}/access.log combined </irtualhost>
userdir.conf (the first half of code original userdir.conf. copied , pasted below original one, , changed public_html public_html2.)
<ifmodule mod_userdir.c> userdir public_html userdir disabled root <directory /home/*/public_html> allowoverride fileinfo authconfig limit indexes options multiviews indexes symlinksifownermatch includesnoexec <limit post options> require granted </limit> <limitexcept post options> require denied </limitexcept> </directory> </ifmodule> <ifmodule mod_userdir.c> userdir public_html2 userdir disabled root <directory /home/*/public_html2> allowoverride fileinfo authconfig limit indexes options multiviews indexes symlinksifownermatch includesnoexec <limit post options> require granted </limit> <limitexcept post options> require denied </limitexcept> </directory> </ifmodule>
i'm not sure 100% understand question, assume asking have 2 different domains each 1 of them uses different userdir.
edit: on right track. thing had missing, needed put each of 2 userdir configs in respective virtualhost config seen below.
for that, need create 2 virtual hosts, , each virtual host have own userdir configurations.
the first virtual host contain following:
# /etc/apache2/sites-available/com.sample.www.conf <virtualhost *:80> servername www.sample.com <ifmodule mod_userdir.c> userdir public_html userdir disabled root <directory /home/*/public_html> allowoverride fileinfo authconfig limit indexes options multiviews indexes symlinksifownermatch includesnoexec <limit post options> require granted </limit> <limitexcept post options> require denied </limitexcept> </directory> </ifmodule> </virtualhost>
the second virtual host contain following:
# /etc/apache2/sites-available/com.sample.www2.conf <virtualhost *:80> servername www2.sample.com userdir public_html2 <ifmodule mod_userdir.c> userdir disabled root <directory /home/*/public_html2> allowoverride fileinfo authconfig limit indexes options multiviews indexes symlinksifownermatch includesnoexec <limit post options> require granted </limit> <limitexcept post options> require denied </limitexcept> </directory> </ifmodule> </virtualhost>
once done, need enable 2 virtual host config files , restart apache.
$ sude a2dissite 000-default.conf $ sudo a2ensite com.sample.www.conf $ sudo a2ensite com.sample.www2.conf $ sudo apache2ctl restart
now, when open www.sample.com/~dan/
use /home/dan/public_html/
, when open www2.sample.com/~dan/
use /home/dan/public_html2/
Comments
Post a Comment