nginx 常用命令 保持启动 重载 开机启动等

nginx
安装 Nginx 服务
查看 Nginx 版本
检查Nginx配置语法正确
启动 Nginx 服务
开机自启动
重启 Nginx 服务
查看 Nginx 服务状态
重载 Nginx 服务吗,配置文件更新,重置载入
停止 Nginx 服务
查看进程,使用lsof命令 ,也查到80端口进程是否有进程在运行。
查看软件安装路径
查询运行文件所在路径
安装 Nginx 服务

yum install epel-release && yum install nginx [On CentOS/RHEL]
dnf install nginx [On Debian/Ubuntu]
apt install nginx [On Fedora]

查看 Nginx 版本

nginx -v

详细的使用:

nginx -V

检查Nginx配置语法正确

nginx -t

启动 Nginx 服务

systemctl start nginx #systemd
or
service nginx start #sysvinit

开机自启动

systemctl enable nginx
or
service nginx enable

重启 Nginx 服务

systemctl restart nginx
or
service nginx restart

查看 Nginx 服务状态

systemctl status nginx
or
service nginx status

重载 Nginx 服务吗,配置文件更新,重置载入(linux nginx)

systemctl reload nginx
or
service nginx reload

停止 Nginx 服务

systemctl stop nginx
or
service nginx stop

查看进程,使用lsof命令 ,也查到80端口进程是否有进程在运行。

lsof -i:80 

查看软件安装路径

whereis nginx

查询运行文件所在路径

which nginx

转载:https://blog.csdn.net/tangkthh/article/details/105898377?spm=1001.2014.3001.5501
参考:https://blog.csdn.net/tangkthh/article/details/105893811?spm=1001.2014.3001.5501

tasklist 查看任务列表

直接点击Nginx目录下的nginx.exe 或者 cmd运行start nginx

关闭

nginx -s stop 或者 nginx -s quit

stop表示立即停止nginx,不保存相关信息

quit表示正常退出nginx,并保存相关信息

重启(因为改变了配置,需要重启)
nginx -s reload

启动
nginx

停止nginx 服务
nginx -s stop

一般配置文件在
/etc/nginx/conf.d/

服务帮助
nginx --help ‘help’

视图

ctrl + v 

y 复制
p 黏贴
d 删除

 #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80//8090;//侦听80端口,可修改为任意没有占用的端口,比如8090
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
默认主页目录在nginx安装目录的html子目录
        location / {
            root   html;
            index  index.html index.htm;
        }


server {
    listen       8083;
    listen  [::]:8083;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;
   
   location /api {
          proxy_pass http://10.27.228.16:8099/api;
          proxy_redirect off;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header   Cookie $http_cookie;
    }

    location / {
        root   /usr/share/nginx/html/dist;
        index  index.html index.htm;
        #try_files $uri $uri/ @router;
    }
    
    #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   /usr/share/nginx/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;
    #}
}



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;

  server {
    listen    9000;
    # server_name  www.llgx.xyz;

    # Load configuration files for the default server block.
     # include /etc/nginx/default.d/*.conf;
     # include /usr/local/nginx/default.d/*.conf;
    
     # include /usr/local/nginx/conf/nginx.conf
    

    location ~ /ems/api {
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_pass http://127.0.0.1:9001;

      # enables WS support
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
    }

    location /ems {
      root /;
      rewrite ^/ems/(.*)$ /home/hc/webProject/ems/index.html break;
    }

    location /ems/static/ {
      alias /home/hc/webProject/ems/static/;
    }

    location /ems/attach/ {
      alias /home/hc/emsFilePath/attach/;
    }
    location /ems/sdk/ {
      alias /home/hc/webProject/ems/sdk/;
    }

    location ~ /emsDpct/api {
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_pass http://127.0.0.1:9002;

      # enables WS support
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
    }

    location /emsDpct {
      root /;
      rewrite ^/emsDpct/(.*)$ /home/hc/webProject/emsDpct/index.html break;
    }

    location /emsDpct/static/ {
      alias /home/hc/webProject/emsDpct/static/;
    }

    location /emsDpct/attach/ {
      alias /home/hc/emsFilePath/attach/;
    }

    location / {
      root /;
      rewrite ^/(.*)$ /home/hc/other/index.html break;
    }

    location ~ /ls(.*) {
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_pass http://117.78.8.105:9020;

      # enables WS support
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
    }

    location /health {
      alias /home/hc/webProject/health;
    }

    location /health1 {
      alias /home/hc/webProject/health1;
    }

    location /big {
      alias /home/hc/webProject/big;
    }
    
    location /data {
      alias /home/hc/webProject/data;
    }

    location ~ /xxl-job-admin {
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_pass http://127.0.0.1:9003;

      # enables WS support
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
    }

  }

}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值