Welcome! Log In Create A New Profile

Advanced

Re: variables in "include" for vhost specific config files

July 21, 2009 05:05AM
On Sun, Jul 19, 2009 at 08:45:07PM +0300, Kaspars wrote:

> Privet Igor and dear list members,
>
> I am trying to create a flexible virtual host environment, where each
> host could have their own config.nginx file.
>
> In sites-available/default I have:
>
> server {
> listen 80 default;
> server_name _;
> server_name_in_redirect off;
>
> set $vhost_path /var/www/vhosts;
>
> root $vhost_path/$host;
> index index.php index.html index.htm;
>
> # THE IMPORTANT BIT: vhost specific config files, for rewrites,
> etc.
> include /var/www/vhosts/$host/config.nginx;
>
> [...]
> }
>
>
> 'root' directive works fine, but the 'include' doesn't like the $host
> variable in it.
>
> I would like to avoid using server { ... } for each of the individual
> hosts, in order to have global php settings.
>
> What would be the best way to approach this?
>
> Any pointers and suggestions are very welcome.
>
> Regards,
> Kaspars
>
> p.s. using nginx 0.6.32-3 on debian lenny.

As it was already discussed, nginx "include"s files on start time,
while "root", etc. substitute variable values on run time.

As to global php settings, you may use

http {

# here you may set any fastcgi settings expect fastcgi_pass,
# and they will be inherited in all servers and locations.
fastcgi_index ...
fastcgi_param ...

server {
...

location \.php$ {
fastcgi_pass ...;
}
}

server {
...

location \.php$ {
fastcgi_pass ...;
}
}

My personal paractice is always to use separate servers since it allows
to change their configuration without risk to break others.


--
Igor Sysoev
http://sysoev.ru/en/
Subject Author Posted

variables in "include" for vhost specific config files

Kaspars July 19, 2009 01:45PM

Re: variables in "include" for vhost specific config files

Igor Sysoev July 21, 2009 05:05AM

Re: variables in "include" for vhost specific config files

mike July 21, 2009 12:57PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 268
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready