Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the ad-inserter domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/blog.webeats.it/httpdocs/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the cookie-law-info domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/blog.webeats.it/httpdocs/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wordpress-seo domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/blog.webeats.it/httpdocs/wp-includes/functions.php on line 6114
Ottimizzare nignx e aumentarne le prestazioni su Ubuntu

Ottimizzare nignx su Ubuntu LTS 14.04 e 16.04 per far gestire un numero maggiore di connessioni ai nostri siti web

Se i nostri siti ricevono molte visite al giorno, il webserver potrebbe essere limitato dalle configurazioni standard del sistema.

In questo caso è necessario ottimizzare il sistema (nel nostro caso Ubuntu) per far sí che riesca a gestire e processare tutte le richieste. Di queste ottimizzazioni ne trarranno beneficio sicuramente i nostri amati CMS come WordPress, Prestashop e Magento.

Gli interventi da seguire sono sostanzialmente 3:

  1. Aggiungiamo queste linee al nostro file sysctl.conf
pico /etc/sysctl.conf

e aggiungiamo alla fine

net.core.somaxconn = 65536
net.ipv4.tcp_max_tw_buckets = 1440000
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_window_scaling = 1	
net.ipv4.tcp_max_syn_backlog = 3240000

2. Modificare il file limits.conf

pico /etc/security/limits.conf

e alla fine aggiungiamo

root soft  nofile 65536
root hard  nofile 65536

www-data soft nofile 65536
www-data hard nofile 65536

3. Ovviamente ora non ci resta che sistemare il file di conf di nginx. Il file di che vi andrò a mostrare è puramente esemplificativo, quindi – specialmente se usate pannelli di gestione come Plesk, ISPConfig, CPanel, VestaCP o altri – le modifiche dovranno essere fatte adhoc. Ecco un file di esempio ottimizzato:

pid /var/run/nginx.pid;
worker_processes  2;
	
events {
    worker_connections   65536;
    use epoll;
    multi_accept on;
}
	
http {
    keepalive_timeout 65;
    keepalive_requests 100000;
    sendfile         on;
    tcp_nopush       on;
    tcp_nodelay      on;
		
    client_body_buffer_size    128k;
    client_max_body_size       10m;
    client_header_buffer_size    1k;
    large_client_header_buffers  4 4k;
    output_buffers   1 32k;
    postpone_output  1460;
		
    client_header_timeout  3m;
    client_body_timeout    3m;
    send_timeout           3m;
		
    open_file_cache max=1000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 5;
    open_file_cache_errors off;
		
    gzip on;
    gzip_min_length  1000;
    gzip_buffers     4 4k;
    gzip_types       text/html application/x-javascript text/css application/javascript text/javascript text/plain text/xml application/json application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype application/x-font-ttf application/xml font/eot font/opentype font/otf image/svg+xml image/vnd.microsoft.icon;
    gzip_disable "MSIE [1-6]\.";

    # [ debug | info | notice | warn | error | crit | alert | emerg ] 
    error_log  /var/log/nginx.error_log  warn;
		
    log_format main      '$remote_addr - $remote_user [$time_local]  '
      '"$request" $status $bytes_sent '
      '"$http_referer" "$http_user_agent" '
  		'"$gzip_ratio"';

    log_format download  '$remote_addr - $remote_user [$time_local]  '
      '"$request" $status $bytes_sent '
      '"$http_referer" "$http_user_agent" '
  		'"$http_range" "$sent_http_content_range"';
		
    map $status $loggable {
        ~^[23]  0;
        default 1;
    } 
		
    server {
        listen        127.0.0.1;
        server_name   127.0.0.1;
        root         /var/www/html;
        access_log   /var/log/nginx.access_log  main;
			
        location / {
            proxy_pass         http://127.0.0.1/;
            proxy_redirect     off;
            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_connect_timeout      90;
            proxy_send_timeout         90;
            proxy_read_timeout         90;
            proxy_buffer_size          4k;
            proxy_buffers              4 32k;
            proxy_busy_buffers_size    64k;
            proxy_temp_file_write_size 64k;
            proxy_temp_path            /etc/nginx/proxy_temp;
        }
			
        location ~* .(woff|eot|ttf|svg|mp4|webm|jpg|jpeg|png|gif|ico|css|js)$ {
            expires 365d;
        }
    }
}

Ovviamente suggerisco di abbinare l’uso di PHP-FPM per avere il massimo delle prestazioni.

Link all’articolo completo e più approfondito