Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx variable for path of config file

Tags:

nginx

config

Is there a way to specify, for example, that the root should be relative to the directory where the config file is living? Something like

root $conf_path/www
like image 255
Jared Forsyth Avatar asked Feb 17 '23 09:02

Jared Forsyth


1 Answers

You can actually do that using the -p option.

If you have your config file in the same directory as your app you can run:

/your/folder $ sudo nginx -c `pwd`/nginx.conf -p "`pwd`"

from your app folder.
Your nginx.conf file changes from:

http {
    include mime.types;
    root /your/folder;
    server {
        listen 8000;
    }
}

to

http {
    include /etc/nginx/mime.types;
    root .;
    server {
        listen 8000;
    }
}

just make sure that you check relative links that pointed to /etc/nginx/

like image 79
Renaud Avatar answered Feb 25 '23 10:02

Renaud