Teknotit Snipet Manager



Api 2 Git 1 aleatoire 2 animation 1 apache2 4 bash 9 cache 1 css 17 curl 1 fastcgi 2 fichier 1 fonctions 10 html 5 inspiration 1 javascript 17 linux 17 mobile 2 mysql 2 nginx 3 php 21 postfix 2 repertoire 3 ssh 9 swap 1 sysadmin 13 taille 1 ubuntu 7 wordpress 8

.

nginx

Nginx exemple de configuration (php fastcgi)

server {
    # .domain.com will match both domain.com and anything.domain.com
    server_name .example.com;
 
    # It is best to place the root of the server block at the server level, and not the location level
    # any location block path will be relative to this root. 
    root /usr/local/www/example.com;
 
    # It's always good to set logs, note however you cannot turn off the error log
    # setting error_log off; will simply create a file called 'off'.
    access_log /var/log/nginx/example.access.log;
    error_log /var/log/nginx/example.error.log;
 
    # This can also go in the http { } level
    index index.html index.htm index.php;
 
    location / { 
        # if you're just using wordpress and don't want extra rewrites
        # then replace the word @rewrites with /index.php
        try_files $uri $uri/ @rewrites;
    }
 
    location @rewrites {
        # Can put some of your own rewrite rules in here
        # for example rewrite ^/~(.*)/(.*)/? /users/$1/$2 last;
        # If nothing matches we'll just send it to /index.php
        rewrite ^ /index.php last;
    }
 
    # This block will catch static file requests, such as images, css, js
    # The ?: prefix is a 'non-capturing' mark, meaning we do not require
    # the pattern to be captured into $1 which should help improve performance
    location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
        # Some basic cache-control for static files to be sent to the browser
        expires max;
        add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    }
 
    # remove the robots line if you want to use wordpress' virtual robots.txt
    location = /robots.txt  { access_log off; log_not_found off; }
    location = /favicon.ico { access_log off; log_not_found off; }    
 
    # this prevents hidden files (beginning with a period) from being served
    location ~ /\.          { access_log off; log_not_found off; deny all; }
 
    location ~ \.php {
            fastcgi_param  QUERY_STRING       $query_string;
            fastcgi_param  REQUEST_METHOD     $request_method;
            fastcgi_param  CONTENT_TYPE       $content_type;
            fastcgi_param  CONTENT_LENGTH     $content_length;
 
            fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
            fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
            fastcgi_param  REQUEST_URI        $request_uri;
            fastcgi_param  DOCUMENT_URI       $document_uri;
            fastcgi_param  DOCUMENT_ROOT      $document_root;
            fastcgi_param  SERVER_PROTOCOL    $server_protocol;
 
            fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
            fastcgi_param  SERVER_SOFTWARE    nginx;
 
            fastcgi_param  REMOTE_ADDR        $remote_addr;
            fastcgi_param  REMOTE_PORT        $remote_port;
            fastcgi_param  SERVER_ADDR        $server_addr;
            fastcgi_param  SERVER_PORT        $server_port;
            fastcgi_param  SERVER_NAME        $server_name;
 
            fastcgi_pass 127.0.0.1:9000;
    }
}

fastcgi nginx

http://kbeezie.com/nginx-configuration-examples/

<iframe width="100%" height="1460" src="http://snipet.teknotit.com/index.php?embed=54408e4304a39" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 17/10/2014

Tuning Nginx for Best Performance

# This number should be, at maximum, the number of CPU cores on your system. 
# (since nginx doesn't benefit from more than one worker per CPU.)
worker_processes 24;
 
# Number of file descriptors used for Nginx. This is set in the OS with 'ulimit -n 200000'
# or using /etc/security/limits.conf
worker_rlimit_nofile 200000;
 
 
# only log critical errors
error_log /var/log/nginx/error.log crit
 
 
# Determines how many clients will be served by each worker process.
# (Max clients = worker_connections * worker_processes)
# "Max clients" is also limited by the number of socket connections available on the system (~64k)
worker_connections 4000;
 
 
# essential for linux, optmized to serve many clients with each thread
use epoll;
 
 
# Accept as many connections as possible, after nginx gets notification about a new connection.
# May flood worker_connections, if that option is set too low.
multi_accept on;
 
 
# Caches information about open FDs, freqently accessed files.
# Changing this setting, in my environment, brought performance up from 560k req/sec, to 904k req/sec.
# I recommend using some varient of these options, though not the specific values listed below.
open_file_cache max=200000 inactive=20s; 
open_file_cache_valid 30s; 
open_file_cache_min_uses 2;
open_file_cache_errors on;
 
 
# Buffer log writes to speed up IO, or disable them altogether
#access_log /var/log/nginx/access.log main buffer=16k;
access_log off;
 
 
# Sendfile copies data between one FD and other from within the kernel. 
# More efficient than read() + write(), since the requires transferring data to and from the user space.
sendfile on; 
 
 
# Tcp_nopush causes nginx to attempt to send its HTTP response head in one packet, 
# instead of using partial frames. This is useful for prepending headers before calling sendfile, 
# or for throughput optimization.
tcp_nopush on;
 
 
# don't buffer data-sends (disable Nagle algorithm). Good for sending frequent small bursts of data in real time.
tcp_nodelay on; 
 
 
# Timeout for keep-alive connections. Server will close connections after this time.
keepalive_timeout 30;
 
 
# Number of requests a client can make over the keep-alive connection. This is set high for testing.
keepalive_requests 100000;
 
 
# allow the server to close the connection after a client stops responding. Frees up socket-associated memory.
reset_timedout_connection on;
 
 
# send the client a "request timed out" if the body is not loaded by this time. Default 60.
client_body_timeout 10;
 
 
# If the client stops reading data, free up the stale client connection after this much time. Default 60.
send_timeout 2;
 
 
# Compression. Reduces the amount of data that needs to be transferred over the network
gzip on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
gzip_disable "MSIE [1-6]\.";

nginx

http://dak1n1.com/blog/12-nginx-performance-tuning

<iframe width="100%" height="1676" src="http://snipet.teknotit.com/index.php?embed=54408ddca7a57" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 17/10/2014

Nginx FastCGI cache

user www-data www-data;
worker_processes 1;
lock_file /run/lock/nginx.lock;
 
 
events {
    worker_connections 1024;
}
 
 
http {
    server_tokens off;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay off;
    keepalive_timeout 5;
 
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
 
    gzip on;
    gzip_static on;
    gzip_comp_level 2;
    gzip_disable "msie6";
    gzip_proxied any;
    gzip_types application/javascript application/json application/vnd.ms-fontobject application/x-font-ttf image/svg+xml text/css text/plain text/xml;
    gzip_vary on;
 
    fastcgi_cache_path /var/cache/nginxfastcgi levels=1:2 keys_zone=fastcgicache:10m inactive=10m max_size=64m;
    fastcgi_cache_key $scheme$request_method$host$request_uri;
    # note: can also use HTTP headers to form the cache key, e.g.
    #fastcgi_cache_key $scheme$request_method$host$request_uri$http_x_custom_header;
    fastcgi_cache_lock on;
    fastcgi_cache_use_stale error timeout invalid_header updating http_500;
    fastcgi_cache_valid 5m;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
 
    index index.php;
 
 
    server {
        listen 127.0.0.1:80;
        server_name sitename.com;
 
 
        root /var/www/sitename.com;
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
 
        # example FastCGI cache exception rules
        set $fastcgi_skipcache 0;
 
        if ($query_string) {
            set $fastcgi_skipcache 1;
        }
 
        if ($http_x_custom_header) {
            set $fastcgi_skipcache 0;
        }
 
        if ($uri ~ "/path/matches/") {
            set $fastcgi_skipcache 1;
        }
 
        if ($http_cookie ~ "users_login_cookie") {
            set $fastcgi_skipcache 1;
        }
 
        include /etc/nginx/conf/phpfastcgicache;
 
        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }
 
        location ~ "\.php$" {
            fastcgi_index index.php;
            if (!-f $realpath_root$fastcgi_script_name) {
                return 404;
            }
 
            # note: adds a HTTP response header "X-Cache" returning HIT/MISS/BYPASS/EXPIRED for cache use status
            add_header X-Cache $upstream_cache_status;
            fastcgi_cache fastcgicache;
            fastcgi_cache_bypass $fastcgi_skipcache;
            fastcgi_no_cache $fastcgi_skipcache;
 
            include /etc/nginx/fastcgi_params;
            fastcgi_pass unix:/run/php5/php-fpm.sock;
        }
    }
}

nginx fastcgi cache

https://gist.github.com/magnetikonline/10450786

<iframe width="100%" height="1820" src="http://snipet.teknotit.com/index.php?embed=54408d4cd9e00" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 17/10/2014

Flux RSS de cette page


Teknotit Snipet Manager 1.84 par Bronco - Page générée en 0.006 s