문제

I am new to nginx and i tried a lot to figure out what is going wrong but couldnt.

First, I added a html file "welcome.html" in /usr/share/nginx/html/data/www. Then I could access it in my browser using, localhost/data/www/welcome.html.

Then I added the following code in the nginx.conf file in /etc/bin/nginx/nginx.conf:

server
{
    location /
    {
        root /data/www;
    }
}

After that, i reloaded the configurations using, sudo nginx -s reload. This gave no errors!

But, after this I tried to access my file using "localhost/welcome.html" but it shows an error 404! Although I can still access the file at "localhost/data/www/welcome.html". Please tell me where am I going wrong ?

도움이 되었습니까?

해결책

You have to use absolute path in root directive. So use:

root /usr/share/nginx/html/data/www;

Also nginx does not reload if it sees errors in config, so check your config with nginx -t.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top