您的位置:时时app平台注册网站 > 时时app平台注册网站 > Nginx 命令时时app平台注册网站

Nginx 命令时时app平台注册网站

2019-12-06 12:29

nginx 反向代理 runserver

location / {
           proxy_pass http://www.pipixia957.cn:8000;  #反向代理设置
           proxy_set_header X-real-ip $remote_addr;
           proxy_set_header Host $http_host;
        }


[uwsgi]
http=0.0.0.0:8000
chdir=/home/ubuntu/pro/project
wsgi-file=project/wsgi.py
processes=2
threads=2
master=True
pidfile=uwsgi.pid
daemonize=uwsgi.log

runserver启动
#访问不需要加端口
  1. 检查配置文件是否正确

二、

nginx 负载均衡

upstream mycom{
    ip_hash;
    server 10.11.0.1:8000;  #负载均衡服务器群
    server 10.11.0.1:8000;
    server 10.11.0.1:8000  down;
}

location / {   
            include uwsgi_params;
            uwsgi_pass mycom; #连接负载均衡服务器
        }

poechant@ubuntu:/user/local/nginx$ ./sbin/nginx -?

    $ rpm -ql nginx

nginx静态文件配置

location /static{
            alias  /var/www/myApp/static;
        }
sudo mkdir -vp /var/www/myApp/static/
sudo chmod 777 /var/www/myApp/static/

#工程目录settings下配置静态文件
STATIC_ROOT = '/var/www/myApp/static'
STATIC_URL = '/static/'

#迁移静态文件
python manage.py collectstatic

#settings目录中
DEBUG = Flase
ALLOW_HOST = ['*']

如果显示如上,则表示配置文件正确。否则,会有相关提示。

 

nginx uwsgi启动

 location / {
            include uwsgi_params;
            uwsgi_pass www.pipixia957.cn:8000;
        }

[uwsgi]
socket=0.0.0.0:8000
chdir=/home/ubuntu/pro/project
wsgi-file=project/wsgi.py
processes=2
threads=2
master=True
pidfile=uwsgi.pid
daemonize=uwsgi.log

#访问不需要再加端口

poechant@ubuntu:/user/local/nginx$ ./sbin/nginx -h

三、

如果出现如上的提示信息,表示没有访问错误日志文件和进程,可以sudo(super user do)一下:

  配置文件详解:

或者:

  yum -y install nginx     # 以最简单的方式安装,熟悉应用为主

 

    root     3549     0.0 0.2     108900     2036     ?     Ss     18:42     0:00     nginx: master process     /usr/sbin/nginx -c /etc/nginx/nginx.conf
    nginx     3550     0.0 0.2     109328     2740     ?     S     18:42     0:00     nginx: worker process 
    nginx     3551     0.0 0.2     109328     2720     ?     S     18:42     0:00     nginx: worker process

poechant@ubuntu:service nginx reload

    tcp     0     0     0.0.0.0:80      0.0.0.0:*      LISTEN     3549/nginx
    tcp     0     0     :::80               :::*               LISTEN     3549/nginx

  1. Nginx 重载配置

一、

  1. 查看 Nginx 版本

    nginx-1.10.2-1.el6.x86_64

  1. 停止 Nginx

    $ chkconfig nginx on

poechant@ubuntu:sudo ./sbin/nginx -s reload

  5.查看开启的进程

  1. 指定配置文件

  1.安装完毕,查看下软件版本:

[root@centos-1-22 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
[root@centos-1-22 sbin]# ./nginx -h
nginx version: nginx/1.0.15
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]

    $ service nginx start

-c表示configuration,指定配置文件。

  4.查看网络服务状态

  1. 启动 Nginx          /usr/local/nginx/sbin/nginx

    $ netstat -anptu | grep --color ':80'

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

  2.查看下安装清单:

poechant@ubuntu:sudo ./sbin/nginx -c /usr/local/nginx/conf/nginx.conf

    或

有两种可以查看 Nginx 的版本信息的参数。第一种如下:

  3.启动并设置为开机自启

poerchant@ubuntu:/usr/local/nginx$ sudo ./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

    nginx version: nginx/1.10.2

poechant@ubuntu:/usr/local/nginx$ ./sbin/nginx -v
nginx: nginx version: nginx/1.0.0

    /etc/logrotate.d/nginx
    /etc/nginx/conf.d/default.conf
    /etc/nginx/conf.d/ssl.conf
    /etc/nginx/conf.d/virtual.conf
    /etc/nginx/fastcgi.conf
    /etc/nginx/fastcgi.conf.default
    /etc/nginx/fastcgi_params
    /etc/nginx/fastcgi_params.default
    /etc/nginx/koi-utf
    /etc/nginx/koi-win
    /etc/nginx/mime.types
    /etc/nginx/mime.types.default
    /etc/nginx/nginx.conf     # 主配置文件
    /etc/nginx/nginx.conf.default
    /etc/nginx/scgi_params
    /etc/nginx/scgi_params.default
    /etc/nginx/uwsgi_params
    /etc/nginx/uwsgi_params.default
    /etc/nginx/win-utf
    /etc/rc.d/init.d/nginx     # 开机自启动脚本
    /etc/sysconfig/nginx
    /usr/lib64/nginx/modules
    /usr/sbin/nginx     # 启动脚本
    /usr/share/doc/nginx-1.10.2
    /usr/share/doc/nginx-1.10.2/CHANGES
    /usr/share/doc/nginx-1.10.2/LICENSE
    /usr/share/doc/nginx-1.10.2/README
    /usr/share/doc/nginx-1.10.2/README.dynamic
    /usr/share/doc/nginx-1.10.2/UPGRADE-NOTES-1.0-to-1.10
    /usr/share/man/man3/nginx.3pm.gz
    /usr/share/man/man8/nginx.8.gz
    /usr/share/nginx/html/404.html     # 网
    /usr/share/nginx/html/50x.html     # 页
    /usr/share/nginx/html/index.html     # 的
    /usr/share/nginx/html/nginx-logo.png     # 目
    /usr/share/nginx/html/poweredby.png     # 录
    /usr/share/vim/vimfiles/ftdetect/nginx.vim
    /usr/share/vim/vimfiles/indent/nginx.vim
    /usr/share/vim/vimfiles/syntax/nginx.vim
    /var/lib/nginx
    /var/lib/nginx/tmp
    /var/log/nginx     # 日志文件

另一种显示的是详细的版本信息:

    $ /usr/sbin/nginx -v

 

    $ ps aux | grep -v 'grep' | grep --color 'nginx'

  1. 显示帮助信息

    $ rpm -q nginx

poechant@ubuntu:sudo ./sbin/nginx

上述是采用向 Nginx 发送信号的方式,或者使用:

-s都是采用向 Nginx 发送信号的方式。

poechant@ubuntu:/usr/local/nginx$ ./sbin/nginx -V
nginx: nginx version: nginx/1.0.0
nginx: built by gcc 4.3.3 (Ubuntu 4.3.3-5ubuntu4)
nginx: TLS SNI support enabled
nginx: configure arguments: --with-http_ssl_module --with-openssl=/home/luming/openssl-1.0.0d/

poechant@ubuntu:sudo ./sbin/nginx -s stop
poechant@ubuntu:sudo ./sbin/nginx -s quit

poechant@ubuntu:/usr/local/nginx$ ./sbin/nginx -t
nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied)
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
2012/01/09 16:45:09 [emerg] 23898#0: open() "/usr/local/nginx/logs/nginx.pid" failed (13: Permission denied)
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

本文由时时app平台注册网站发布于时时app平台注册网站,转载请注明出处:Nginx 命令时时app平台注册网站

关键词: