kougami
kougami

Reputation: 904

%1 in ErrorLog/CustomLog in Apache conf

I currently have a web server set up as a development environment and my DNS set up so that basically any subdomain is valid, ie *.mydomain.com. I've achieved this with the following VirtualHost section in my Apache config, with /var/www/html/%1 being the subdomain's document root:

<VirtualHost x.x.x.x:80>
    ...
    ServerName %1.mydomain.com
    DocumentRoot /var/www/html
    VirtualDocumentRoot "/var/www/html/%1"
    LogFormat "%V %h %l %u %t \"%t\" %s %b" vcommon
    ErrorLog /var/log/httpd/error.log
    CustomLog /var/log/httpd/access.log combined
</VirtualHost>

HOWEVER, I'm trying to make the ErrorLog and CustomLog write to files in a more relevant directory by using:

    ErrorLog "/var/www/html/%1/error.log"
    CustomLog "/var/www/html/%1/access.log" combined

And this breaks things. Apache won't start and reports:

No such file or directory: [client AH02291: Cannot access directory '/var/www/html/%1/' for error log[...]

It seems to me that the ErrorLog and CustomLog options aren't expanding/evaluating %1 in the same way that VirtualDocumentRoot is, so my question is, quite succinctly, how can I make it do that?

Thanks in advance.

Upvotes: 0

Views: 563

Answers (1)

Barry Pollard
Barry Pollard

Reputation: 45870

An Apache log is per vhost so this is not possible.

Best I can think of would be to have some process grep the Apache log files periodically to create the artificial logs.

Upvotes: 0

Related Questions