logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: One Virtual Host for multiple subdomains, different logfiles
Author
Ooypunk



Joined: 24 Sep 2012
Posts: 2
Location: NL

PostPosted: Mon 24 Sep '12 15:46    Post subject: One Virtual Host for multiple subdomains, different logfiles Reply with quote

Hello,
I'm setting up a WordPress MultiSite, subdomain style. This is all working nicely, but now I'd like to have some differences, depending on the subdomain chosen. One difference would be a different logfile, another would be a different Alias. Is this possible?

I tried this, but apparently the variables don't work in these places:
Code:
<VirtualHost *:80>
   ServerAdmin me@company.com
   ServerName domain1.net
   ServerAlias *.domain1.net
   ServerAlias www.domain1.net

   DocumentRoot /var/www/working_copies/domain1.net
   <Directory /var/www/working_copies/domain1.net>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all
   </Directory>

   Alias /images /var/www/working_copies/domain1.net/images/${HTTP_HOST}

   ErrorLog ${APACHE_LOG_DIR}/${HTTP_HOST}_error.log
   LogLevel warn
   CustomLog ${APACHE_LOG_DIR}/${HTTP_HOST}_access.log combined
</VirtualHost>
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Mon 24 Sep '12 16:08    Post subject: Reply with quote

You can try to use the apache environment variables.

untested
Code:

LogFormat "%h \"%r\" %>s \"%{Referer}i\" \"%{User-Agent}i\"" vhostformat

SetEnvIfNoCase Host example\.com mainlog
CustomLog /var/log/httpd-example.log vhostformat env=mainlog

SetEnvIfNoCase Host test1\.example\.com vhost1log
CustomLog /var/log/httpd-access_test1.log vhostformat env=vhost1log

SetEnvIfNoCase Host test2\.example\.com vhost2log
CustomLog /var/log/httpd-access_test2.log vhostformat env=vhost2log

SetEnvIfNoCase Host test3\.example\.com vhost3log
CustomLog /var/log/httpd-access_test3.log vhostformat env=vhost3log



I prefer mod_macro http://people.apache.org/~fabien/mod_macro/
Back to top
Ooypunk



Joined: 24 Sep 2012
Posts: 2
Location: NL

PostPosted: Tue 25 Sep '12 9:46    Post subject: Reply with quote

Tried your code and it works like a charm.
One thing though, this only works for logs, not for the Alias command.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Tue 25 Sep '12 10:05    Post subject: Reply with quote

Maybe you find an idea in http://httpd.apache.org/docs/2.2/vhosts/mass.html
I haven't done that yet.

using mod_macro makes it easy to setup a lot of vhosts. That is what I use.
Back to top


Reply to topic   Topic: One Virtual Host for multiple subdomains, different logfiles View previous topic :: View next topic
Post new topic   Forum Index -> Apache