Necessary adjustments

Several core directives deserve to be adjusted carefully upon preparing the initial setup of Nginx on your server. We will review several of these directives and the possible values you may set:

  • user root;This directive specifies that the worker processes will be started as root. It is dangerous for security, as it grants Nginx full permissions over your file system. You need to create a new user account on your system and make use of it here. Recommended value (granted that a www-data user account and group exist on the system) user www-data www-data;.
  • worker_processes 1;With this setting, only one worker process will be started, which implies that all requests will be processed by a unique execution flow. This also implies that the execution is delegated to only one core of your CPU. It is highly recommended to increase this value; you should have at least one process per CPU core. Alternatively, just set this to auto to leave it up to Nginx to determine the optimal value. Recommended value: worker_processes auto;.
  • worker_priority 0;By default, the worker processes are started with a regular priority. If your system performs other tasks simultaneously, you might want to grant a higher priority to the Nginx worker processes. In this case, you should decrease the value; the smaller the value, the higher the priority. Values range from -20 (highest priority) to 19 (lowest priority). There is no recommended value here, as it completely depends on your situation. However, you should not set it under -5as it is the default priority for kernel processes.
  • log_not_found on;This directive specifies whether Nginx should log 404 errors or not. While these errors may of course provide useful information about missing resources, a lot of them may be generated by web browsers trying to reach the favicon (the conventional /favicon.ico of a website) or robots trying to access the indexing instructions (robots.txt). Set this to off if you want to ensure your log files don't get cluttered by Error 404 entries, but keep in mind that this could deprive you from potentially important information about other pages that visitors failed to reach. Note that this directive is part of the HTTP core module. Refer to the next chapter for more information.
  • worker_connections 1024;This setting, combined with the amount of worker processes, allows you to define the total amount of connections accepted by the server simultaneously. If you enable four worker processes, each accepting 1,024 connections, your server will treat a total of 4,096 simultaneous connections. You need to adjust this setting to match your hardware: the more RAM and CPU power your server relies on, the more connections you can accept concurrently. If your server is a huge monster meant to host high traffic sites, you will want to increase this value.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.235.99