Issue with variables in access_log and error_log

dale gallagher dale.gallagher at gmail.com
Wed Jul 29 21:30:57 MSD 2009


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)

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