Created a folder /data/www as stated in the instructions for off. site. In it put the index.html file. Then I opened the configuration file and added the following to the end of the http block (which was already there):

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

Next, reboot the nginx daemon like this: sudo nginx -s reload .

After all this, I go to http: //localhost/index.html . I see 404 in response. What am I doing wrong?

Ubuntu system 16.04.

  • By debian / ubunt standards, the configuration of your server should be in the sites-available folder and linked to sites-enabled. And it would be necessary to remove the default from there - Alexey Ten
  • Thank. And you can a little more? - faoxis
  • In the / etc / nginx / sites-available subdirectory, all configs are added, even those that you previously used and now do not use. In sites-enabled (in the main config there is a include config from this directory), the used configs are added, it is customary to make them symlinks to configs in sites-available. - Ivan Pshenitsyn

1 answer 1

I guess you didn’t adequately describe the server configuration for nginx. Do not specify the domain (server_name) and port (listen). The minimum server config should look something like this:

 server { listen 80; server_name localhost; access_log logs/localhost.access.log; root /data/www/; location /images/ { root /data/; } } 
  • Error: nginx: [emerg] unknown log format "main" in /etc/nginx/nginx.conf:66 - faoxis
  • try to fix this line on access_log logs / localhost.access.log; or even comment it out with the # at the beginning of the line. The main thing now is not logs, with them and then we'll figure it out. - Ivan Pshenitsyn
  • Commented out. The result is the same - 404. - faoxis
  • did nginx restart do? reload, if I am not mistaken, is insufficient for such serious changes in the config as adding a server. If restartili and still does not work - show the full config, please. - Ivan Pshenitsyn
  • one
    Found what's the matter. The default file / etc / nginx / sites-enabled / default was connected to my config, which interrupted my config. After I deleted it, everything worked. Thanks for the help. ) - faoxis