NGinx Default public www location?

前端 未结 30 941
野性不改
野性不改 2020-11-28 17:51

I have worked with Apache before, so I am aware that the default public web root is typically /var/www/.

I recently started working with nginx, but I ca

相关标签:
30条回答
  • 2020-11-28 17:53

    If your configuration does not include a root /some/absolute/path; statement, or it includes one that uses a relative path like root some/relative/path;, then the resulting path depends on compile-time options.

    Probably the only case that would allow you to make an educated guess as to what this means for you would be, if you downloaded and compiled the source yourself. In that case, the paths would be relative to whatever --prefix was used. If you didn't change it, it defaults to /usr/local/nginx. You can find the parameters nginx was compiled with via nginx -V, it lists --prefix as the first one.

    Since the root directive defaults to html, this would, of course, result in /usr/local/nginx/html being the answer to your question.

    However, if you installed nginx in any other way, all bets are off. Your distribution might use entirely different default paths. Learning to figure out what kind of defaults your distribution of choice uses for things is another task entirely.

    0 讨论(0)
  • 2020-11-28 17:56

    For Ubuntu and docker images:

    /usr/share/nginx/html/

    0 讨论(0)
  • 2020-11-28 17:56

    For AWS EC2 Linux you will find here:

    /usr/share/nginx
    
    0 讨论(0)
  • 2020-11-28 17:56

    You can search for it, no matter where did they move it (system admin moved or newer version of nginx)

    find / -name nginx

    0 讨论(0)
  • 2020-11-28 17:57

    My nginx on Ubuntu is "nginx version: nginx/1.9.12 (Ubuntu)" and root path is /var/www/html/

    Ubuntu info is : No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04 LTS Release: 16.04 Codename: xenial

    Actually, if you just installed nginx on Ubuntu, then you can go to "/etc/nginx/sites-available" and check the default file, there is a configuration like "root /web/root/path/goes/here". And that is what you are looking for.

    0 讨论(0)
  • 2020-11-28 17:58

    Look into nginx config file to be sure. This command greps for whatever is configured on your Machine:

    cat /etc/nginx/sites-enabled/default |grep "root"
    

    on my machine it was :root /usr/share/nginx/www;

    0 讨论(0)
提交回复
热议问题