HAVENT原创centOS 下 nginx 配置和启动

Posted havent

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HAVENT原创centOS 下 nginx 配置和启动相关的知识,希望对你有一定的参考价值。

nginx 手动启动停止

[[email protected] nginx-1.13.3]# cd /usr/local/nginx/sbin/

// 启动 nginx
[[email protected] sbin]# ./nginx

// 停止 nginx(此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程)
[[email protected] sbin]# ./nginx -s stop

// 停止 nginx(此方式停止步骤是待nginx进程处理任务完毕进行停止)
[[email protected] sbin]# ./nginx -s quit

// 重新加载配置文件(修改配置文件 nginx.conf 可以使用该命令使配置生效)
[[email protected] sbin]# ./nginx -s reload

// 查询 nginx 进程
[[email protected] sbin]# ps aux | grep nginx

 

nginx 配置信息

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


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_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    #gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary off;
    gzip_disable "MSIE [1-6]\.";

    server {
        listen       81;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            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;
    #    }
    #}

    # HAVENT Add Module ----------------- OP
        server {
            listen    80;
            server_name  www.my00.com;

            root html;

            access_log  logs/my00_com.access.log;

            location / {
                root   /www/my00_com/;
            }

            error_page   500 502 503 504 /50x.html;
            location = /50x.html {
            }


            location ~ /.ht {
                deny all;
            }
        }

        server {
            listen    80;
            server_name  admin.my00.com;

            root html;

            access_log  logs/admin.access.log;

            location / {
                # index index.php index.html index.htm;

                proxy_pass http://127.0.0.1:8001;
            }

            error_page   500 502 503 504 /50x.html;
            location = /50x.html {
            }

            location ~ ^/(images|javascript|js|css|flash|media|static)/ {
                expires 30d;
            }

            location ~ /.ht {
                deny all;
            }

        }

        server {
            listen    80;
            server_name  demo.my00.com www.os1.cc;

            root html;

            access_log  logs/demo_my00_com.access.log;

            location / {
                root   /www/os1_cc/;
            }

            location ^~ /NeverGiveUp/ {
                alias    /www/my00_com/NeverGiveUp/;
            }

            error_page   500 502 503 504 /50x.html;
            location = /50x.html {
            }


            location ~ /.ht {
                deny all;
            }
        }

    # HAVENT Add Module ----------------- ED

}

 

以上是关于HAVENT原创centOS 下 nginx 配置和启动的主要内容,如果未能解决你的问题,请参考以下文章

HAVENT原创Node Express API 通用配置

HAVENT原创Australian Business Number (ABN) 验证

HAVENT原创Salesforce 给字段加上链接

[原创]Centos7 从零编译配置Nginx

HAVENT原创Docker 创建一个新的 Node 镜像,并发布到 DockerHub

[原创]Centos7 从零编译配置PHP