A really stupid question: how do I set a variable in Nginx' config file? I'd like to set: path=/var/www/mysites/ And then reuse this variable, for instance: root $path/cool_site; But I can't figure out how to do it.
on 09.07.2008 01:36
on 09.07.2008 05:20
set $path /var/www/mysites/;
on 09.07.2008 12:05
Smashing! Thank you Marcos.
on 31.08.2008 13:04
Hu!? I just figured out I have never tested setting a variable in my nginx file. I tried it, and it failed: either it is not placed in the correct area either Nginx complains it doesn't know about "set". I am using Nginx 0.6.31
on 01.09.2008 07:20
On Sun, Aug 31, 2008 at 12:56:54PM +0200, Thomas wrote: > Hu!? I just figured out I have never tested setting a variable in my > nginx file. I tried it, and it failed: either it is not placed in the > correct area either Nginx complains it doesn't know about "set". I am > using Nginx 0.6.31 It seems that you do not build nginx --with-http_rewrite_module.
on 10.09.2008 17:17
Here is an excerpt of my conf file:
---
set $ngx_path /usr/local/nginx/logs;
set $app_path /home/application;
...
root $app_path/myblog;
access_log $ngx_path/access.myblog.log;
---
And here is the error message I get when I start nginx:
------
2008/09/10 17:01:11 [emerg] 588#0: open()
"/usr/local/nginx/$ngx_path/access.myblog.log" failed (2: No such file
or directory)
------
Setting a path variable doesn't work with the log files.
on 11.09.2008 22:48
On Wed, Sep 10, 2008 at 05:06:45PM +0200, Thomas wrote: > ------ > 2008/09/10 17:01:11 [emerg] 588#0: open() > "/usr/local/nginx/$ngx_path/access.myblog.log" failed (2: No such file > or directory) > ------ > > Setting a path variable doesn't work with the log files. access_log supports variables since 0.7.6+ only. BTW, it's not good idea to set some variable to static values on server level and then use them. You may simply define common "root" and "access_log" on server level.