Nginx インストール

Nid: 1149

1 . インストール

$ sudo apt-get install nginx 

バージョン確認

$ nginx -v
nginx version: nginx/1.14.0 (Ubuntu)

2 . 接続確認

クライアントPCから接続確認

http://server_domain_or_IP

3 . 設定

設定ファイル     /etc/nginx/nginx.conf
    /etc/nginx/sites-available
    /etc/nginx/sites-enabled
    /etc/nginx/snippets

$ cat /etc/nginx/nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on; # copies data between one FD and other from within the kernel, faster than read() + write()
        tcp_nopush on; # send headers in one piece, it is better than sending them one by one
        tcp_nodelay on; # don't buffer data sent, good for small data bursts in real time
        types_hash_max_size 2048;
        server_tokens off; # hide Nginx server version on error pages for security
        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;
        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # Timeout Settings
        ##
        reset_timedout_connection on; # allow the server to close connection on non responding client, this will free up memory
        client_body_timeout 10; # request timed out -- default 60
        send_timeout 2; # if client stop responding, free up memory -- default 60
        keepalive_timeout 30; # server will close connection after this time -- default 75

        ##
        # SSL Settings
        ## more in /etc/nginx/snippets/ssl-params.conf

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        #access_log /var/log/nginx/access.log;
        #error_log /var/log/nginx/error.log;
        access_log off; # to boost I/O on HDD
        error_log /var/log/nginx/error.log crit; # only log critical errors

        ##
        # Gzip Settings
        ##

        gzip on; # enables gzip compression
        # gzip_static on;
        gzip_min_length 10240; # not compress anything smaller than the defined size to save CPU
        gzip_comp_level 1; # 9 is the most compressed
        gzip_vary on; # tells proxies to cache both gzipped and regular versions of a resource
        gzip_disable msie6;
        gzip_proxied expired no-cache no-store private auth;
        gzip_types
                # text/html is always compressed by HttpGzipModule
                text/css
                text/javascript
                text/xml
                text/plain
                text/x-component
                application/javascript
                application/x-javascript
                application/json
                application/xml
                application/rss+xml
                application/atom+xml
                font/truetype
                font/opentype
                application/vnd.ms-fontobject
                image/svg+xml;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }
#}

4 . ログファイル

    /var/log/nginx/access.log
    /var/log/nginx/error.log
 

関連記事: