NGinx Default public www location?

前端 未结 30 942
野性不改
野性不改 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 18:15

    In my case it was in /usr/share/nginx/html

    you can try to find by performing a search

    find / -name html
    
    0 讨论(0)
  • 2020-11-28 18:15

    Just to note that the default index page for the nginx server will also display the root location as well. From the nginx (1.4.3) on Amazon Linux AMI, you get the following:

    This is the default index.html page that is distributed with nginx on the Amazon Linux AMI. It is located in /usr/share/nginx/html.

    You should now put your content in a location of your choice and edit the root configuration directive in the nginx configuration file /etc/nginx/nginx.conf

    0 讨论(0)
  • 2020-11-28 18:16

    You can simply map nginx's root folder to the location of your website:

    nano /etc/nginx/sites-enabled/default
    

    inside the default file, look for the root in the server tag and change your website's default folder, e.g. my websites are at /var/www

    server {
            listen 80 default_server;
            listen [::]:80 default_server ipv6only=on;
    
            root /var/www; <-- Here!
    ...
    

    When I was evaluating nginx, apache2 and lighttpd, I mapped all of them to my website sitting at /var/www. I found this the best way to evaluate efficiently.

    Then you can start/stop the server of your choice and see which performs best.

    e.g.

    service apache2 stop
    service nginx start
    

    Btw, nginx actually is very fast!

    0 讨论(0)
  • 2020-11-28 18:16

    Run the command nginx -V and look for the --prefix. Use that entry to locate your default paths.

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

    The default Nginx directory on Debian is /var/www/nginx-default.

    You can check the file: /etc/nginx/sites-enabled/default

    and find

    server {
            listen   80 default;
            server_name  localhost;
    
            access_log  /var/log/nginx/localhost.access.log;
    
            location / {
                    root   /var/www/nginx-default;
                    index  index.html index.htm;
            }
    

    The root is the default location.

    0 讨论(0)
  • 2020-11-28 18:18

    in ubuntu 19.04, we found it on

    /usr/share/nginx/html

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