Nginx 일상 동작 및 설정

13559 단어 nginx
설치 위치: / usr / local / nginx 설정 디 렉 터 리: / usr / local / nginx / conf 설정 파일: / usr / local / nginx / conf / nginx. conf 시작 명령: / usr / local / nginx / sbin / nginx
[root@limt sbin]# /usr/local/nginx/sbin/nginx -h

nginx version: nginx/1.7.9

Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]



Options:

  -?,-h         : this help

  -v            : show version and exit

  -V            : show version and configure options then exit

  -t            : test configuration and exit

  -q            : suppress non-error messages during configuration testing

  -s signal     : send signal to a master process: stop, quit, reopen, reload

  -p prefix     : set prefix path (default: /usr/local/nginx/)

  -c filename   : set configuration file (default: conf/nginx.conf)

  -g directives : set global directives out of configuration file

1         

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

-c         nginx      



[root@limt sbin]# ps -ef|grep nginx

root       4631      1  0 03:17 ?        00:00:00 nginx: master process ./nginx -c /usr/local/nginx/conf/nginx.conf

nobody     4632   4631  0 03:17 ?        00:00:00 nginx: worker process                      

root       4634   4496  0 03:18 pts/0    00:00:00 grep nginx



2            

kill -HUP             (/usr/local/nginx/logs/nginx.pid)

kill -HUP  `cat /usr/local/nginx/logs/nginx.pid`

    

/usr/nginx/sbin/nginx -s reload



3          

[root@limt sbin]# ./nginx -t

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful



4   nginx

    Nginx:

kill -QUIT     

    Nginx:

kill -TERM     

    Nginx:

pkill -9     

기본 설정: / usr / local / nginx / conf / nginx. conf
#  nginx worker           ,  nobody

user  nobody; 

#  nginx       。   CPU                   

worker_processes  2;         



#            。   :debug、info、notice、warn、error crit。debug        ,criti      

#error_log  logs/error.log;

error_log  logs/error.log  notice;

#error_log  logs/error.log  info;



#      id       

pid        logs/nginx.pid;



#  nginx          

events {

    #        :select、poll、kqueue、epoll rtsig.  linux  ,epoll     

    use epoll; 

    #  nginx          

    worker_connections  2048;

}





#HTTP     

http {

    #

    include       mime.types;

    #           

    default_type  application/octet-stream;



    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';



    access_log  logs/access.log  main;



    #            

    sendfile        on;

    #  TCP  

    #tcp_nopush     on;



    #                  ,      ,         

    #keepalive_timeout  0;

    keepalive_timeout  65;



    #

    #gzip  on;



    #    

    server {

        #    

        listen       80;

        #   (  )

        server_name  localhost;



        #web        

        #charset koi8-r;



        access_log  logs/host.access.log  main;



        #  url    "/",          

        location / {

            #         ,    :/opt/nginx/html,       

            root  /var/nginx;

            #            

            index  index.html index.htm;

        }



        #error_page  404              /404.html;



        # redirect server error pages to the static page /50x.html

        #

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }



        # proxy the PHP scripts to Apache listening on 127.0.0.1:80

        #

        #location ~ \.php$ {

        #    proxy_pass   http://127.0.0.1;

        #}



        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        #

        #location ~ \.php$ {

        #    root           html;

        #    fastcgi_pass   127.0.0.1:9000;

        #    fastcgi_index  index.php;

        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

        #    include        fastcgi_params;

        #}



        # deny access to .htaccess files, if Apache's document root

        # concurs with nginx's one

        #

        #location ~ /\.ht {

        #    deny  all;

        #}

    }





    # another virtual host using mix of IP-, name-, and port-based configuration

    #

    #server {

    #    listen       8000;

    #    listen       somename:8080;

    #    server_name  somename  alias  another.alias;



    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}





    # HTTPS server

    #

    #server {

    #    listen       443 ssl;

    #    server_name  localhost;



    #    ssl_certificate      cert.pem;

    #    ssl_certificate_key  cert.key;



    #    ssl_session_cache    shared:SSL:1m;

    #    ssl_session_timeout  5m;



    #    ssl_ciphers  HIGH:!aNULL:!MD5;

    #    ssl_prefer_server_ciphers  on;



    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}



}

좋은 웹페이지 즐겨찾기