Issue with variables in access_log and error_log

Maxim Dounin mdounin at mdounin.ru
Wed Jul 29 21:54:26 MSD 2009


Hello!

On Wed, Jul 29, 2009 at 07:30:57PM +0200, dale gallagher wrote:

> Hi there
>
> I'm running nginx 0.7.61 on Linux. Using spawn-fcgi under damontools
> which runs under a separate uid per virtual host and creates a socket
> /var/run/php/$domain/socket
>
> I've configured nginx as per the config below. Everything works well,
> but including variables in access_log and error_log give the error:
>
> [emerg]: open() "/usr/$webroot/$domain/log/error.log" failed (2: No such
> file or directory)

Directive error_log does not support variables.

Directive access_log do support them, but it's not recomended to 
use variables just to shorten configs as it implies extra [useless] work 
on each request.

Maxim Dounin

>
> This seems to indicate that the variables aren't being expanded
> properly? In particular, the prepended '/usr' part must be from the
> --prefix definition when building nginx???
>
> nginx runs as user 'www' which has write access to each of the
> /var/www/$domain/log directories (by group ownership and 770 perms).
>
> Any pointers would be appreciated.
>
> Thanks
> Dale
>
> ----- config -----
>
> user www;
> .....
> ..
> http {
>   ...
>   server {
>     listen 80;
>
>     server_name _;
>     server_name_in_redirect off;
>
>     set $webroot /var/www;
>
>     set $domain $host;
>     if ($domain ~ "^(w{3}\.)?(.*)") {
>       set $domain $2;
>     }
>
>     access_log $webroot/$domain/log/access.log;
>     error_log $webroot/$domain/log/error.log error;
>
>     root $webroot/$domain/public;
>
>     location / {
>       index index.html index.php index.php4 dispatch.fcgi index.cgi;
>       try_files $uri $uri/ @wordpress;
>     }
>     # serve static files directly
>     location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html)$ {
>       expires 30d;
>     }
>     location ~* \.(ht|conf$|db$|lib$|cfg$|inc$|bak$) {
>       deny all;
>     }
>     location ~ \.php$ {
>       try_files $uri @wordpress;
>       fastcgi_pass   unix:/var/run/php/$domain/socket;
>       fastcgi_index  index.php;
>       fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
>       include        fastcgi_params;
>     }
>     location @wordpress {
>       fastcgi_pass   unix:/var/run/php/$domain/socket;
>       fastcgi_param  SCRIPT_FILENAME $document_root/index.php;
>       include        fastcgi_params;
>     }
>   }
> }
>
>





More information about the nginx mailing list