Welcome! Log In Create A New Profile

Advanced

Use of variables with an include statement

Posted by pannix 
Use of variables with an include statement
October 08, 2011 04:26PM
You can use variables in config files to make life easier like :
- rewrite ^ http://www.example.com$request_uri permanent;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

But how do you use a variable with an include statement.
When you use Wordpress on Nginx with the W3 Total Cache plugin you need to include the nginx.conf file in the document root:
include /srv/www/example.com/public_html/nginx.conf
Basically you could create one config file for wordpress and include it in the config files in sites-available/ for all your wordpress sites. The one thing I haven't figured out is how to pass a variable to an include statement. The following statements don't work:
- include $document_root.'nginx.conf'
- include $document_root$wpnginx_conf (where $wpnginx_conf = nginx.conf)
One of the error messages I got is that it couldn't find the file /etc/nginx/$document_root$wpnginx_conf.
So, how can I solve this? Or is there a way around this?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 266
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