On 23-Dec-99 jg@cyberstorm.demon.co.uk wrote:
Hi there,
Anyone running apache with a domain name that has multiple sub-domains (Gareth->Linux.com, desktops.linux.com.... rings a bell)?
I've got www.linuxnewbie.com working fine with documentroot pointing at /www/lnc, and I'd like to get my.linuxnewbie.com pointing at /www/lnc/my.
Problem is very basic: my.linuxnewbie.com/images/ and my.lnc/whatever no longer work for obvious reason (unless I put horrible symlinks in). I gather this can be overcome with the RewriteEngine/RewriteRule directives, but Apache complains they're not recognised.
SEt up a virtual server. For the virtual server you can make the document root anywhere you like. I generally like to give each virtual server its own CGI directory, whcih is *not* in the main html tree. It might be ~user/local-cgi when the html tree is ~user/public_html.
I also like to give each virtual server its own log file.
The necessary steps are:
1. Create the DNS entries for the new host name. These will probably be CNAME pointers to your main IP. For instance:
; /var/named/named.hosts
@ IN SOA panache-eth.DOMAIN. raph.panache.demon.co.uk. ( 1999008051 ; serial 86400 ; refresh interval 3600 ; retry interval 3600000 ; expire - 42 days 604800 ; minimum 1 week ) IN NS panache-eth.DOMAIN. ; ; loopback address panache-eth IN A 172.16.1.1 IN MX 0 172.16.1.1 craft IN CNAME panache-eth raph IN CNAME panache-eth www IN CNAME panache-eth birse IN CNAME panache-eth
2. Create the necessary directories. Mode should be at least 555.
3. Amend httpd.conf, and restart apache. Sample: # Define the new 'virtual' host. Port 80 is used by default <VirtualHost academy.webwright-uk.com> ServerAdmin webmaster@webwright.n-e-t.co.uk # Define the vrtual document root. Somwherre that the owner can get at. DocumentRoot /home/academy/public_html ServerName academy.webwright-uk.com # Define the log files. ErrorLog /var/httpd/logs/error_log TransferLog /var/httpd/logs/academy.access_log # Give him a privat CGI directory <Directory /home/academy/local-cgi> AllowOverride None Options ExecCGI </Directory> # The private CGI is given a useful alias. /local-cgi and /cgi-bin are # both accessible ScriptAlias /local-cgi/ /home/academy/local-cgi/ # A private icons directory. The name conflicts with the global one and so # will replace it, not supplement it Alias /icons/ /home/academy/public_html/icons/ </VirtualHost>