The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Nginx Optimization

Discussion in 'Workarounds and Optimization' started by Bashed, Nov 12, 2015.

  1. Bashed

    Bashed Well-Known Member

    Joined:
    Dec 18, 2013
    Messages:
    78
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    Hey peeps I've installed Nginx using Ngincp

    Code:
    wget http://nginxcp.com/latest/nginxadmin.tar
    tar xf nginxadmin.tar
    cd publicnginx
    ./nginxinstaller install 
    My question now, how do I optimize it nicely for my server? I have only a few personal domains running on PHP 5.5, Apache 2.4, 16GB RAM, SSD drives. I'm not sure I see any noticeable difference. I'm also running Cloudflare on one of my domains too (Xenforo).

    I also want to install this on my web hosting boxes for shared clients, similar specs but with suPHP/Suhosin enabled on those servers.

    Default Nginx Config:

    Code:
    user  nobody;
    # no need for more workers in the proxy mode
    worker_processes  4;
    error_log  /var/log/nginx/error.log warn;
    worker_rlimit_nofile 20480;
    events {
    worker_connections 5120; # increase for busier servers
    use epoll; # you should use epoll here for Linux kernels 2.6.x
    }
    http {
    server_name_in_redirect off;
    server_names_hash_max_size 10240;
    server_names_hash_bucket_size 1024;
    include    mime.types;
    default_type  application/octet-stream;
    server_tokens off;
    # remove/commentout disable_symlinks if_not_owner;if you get Permission denied error
    # disable_symlinks if_not_owner;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout  5;
    gzip on;
    gzip_vary on;
    gzip_disable "MSIE [1-6]\.";
    gzip_proxied any;
    gzip_http_version 1.0;
    gzip_min_length  1000;
    gzip_comp_level  6;
    gzip_buffers  16 8k;
    # You can remove image/png image/x-icon image/gif image/jpeg if you have slow CPU
    gzip_types    text/plain text/xml text/css application/x-javascript application/xml application/javascript application/xml+rss text/javascript application/atom+xml;
    ignore_invalid_headers on;
    client_header_timeout  3m;
    client_body_timeout 3m;
    send_timeout     3m;
    reset_timedout_connection on;
    connection_pool_size  256;
    client_header_buffer_size 256k;
    large_client_header_buffers 4 256k;
    client_max_body_size 200M;
    client_body_buffer_size 128k;
    request_pool_size  32k;
    output_buffers   4 32k;
    postpone_output  1460;
    proxy_temp_path  /tmp/nginx_proxy/;
    proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=microcache:15m inactive=24h max_size=500m;
    client_body_in_file_only on;
    log_format bytes_log "$msec $bytes_sent .";
    log_format custom_microcache '$remote_addr - $remote_user [$time_local] '
            '"$request" $status $body_bytes_sent '
            '"$http_referer" "$http_user_agent" nocache:$no_cache';
    include "/etc/nginx/vhosts/*";
    }
    
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,811
    Likes Received:
    671
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  3. Bashed

    Bashed Well-Known Member

    Joined:
    Dec 18, 2013
    Messages:
    78
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    Thanks. In the meantime, would you be able to explain how I can benchmark the sites with Nginx?
     
  4. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,470
    Likes Received:
    198
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Lots of results on google for the above term.
     
Loading...

Share This Page