[Introduction] Nginx and installation, startup, shutdown

I. Overview

  1. Nginx is a lightweight Web server / reverse proxy server and e-mail (IMAP / POP3) proxy server , and released under a BSD-like agreement. The program developed by Russian designer Igor Sysoev, Russia for large-scale web portal and search engine Rambler (Russian: Рамблер) use. It features occupy less memory, high concurrency, the ability to do concurrent nginx fact the same type of web server performance is better. Mainland China use nginx web site users are: Sina, Netease, Tencent and so on.
  2. Nginx is a high-performance Web server and reverse proxy, which has had a lot of very superior characteristics :
    • As a Web server: compared to Apache, Nginx use fewer resources to support more concurrent connections, reflecting higher efficiency, especially by this point the Nginx web hosting provider welcome. In response capable of supporting up to 50,000 concurrent connections, thanks to Nginx we chose epoll and kqueue as a development model for us.
    • As a load balancing server: Nginx either directly support Rails and PHP internally, can also support as an HTTP proxy server in foreign service. Nginx is written in C , regardless of the system or CPU resource consumption efficiency is much better than Perlbal.
    • As a mail proxy server: Nginx is also a very good mail proxy server (one of the purposes of the earliest development of this product is as a mail proxy server), Last.fm describes a successful and wonderful experience.
    • Nginx installation is very simple, very simple configuration file (also supports perl syntax), Bugs very little server: Nginx starts are particularly vulnerable, and can be done almost 7*24uninterrupted operation, even running a few months does not need to be restarted . You can also upgrade the software version in the case of uninterrupted service.
  3. Nginx average user seven load balancing , throughput certain restrictions. In order to improve the overall throughput will be introduced between DNS and Nginx LVS (software load balancer), F5 (hardware load balancer) can do four load balancing, DNS resolution first to LVS (F5), so that after LVS ( F5) forwarded to Nginx, forwarded by the real server to Nginx

Two, Nginx basic installation

2.1 Windows install Nginx

解压:nginx-windows
双击: nginx.exe
 
能看到nginx欢迎界面说明,nginx安装成功
演示下 nginx做静态服务器
    
启动Nginx
C:\server\nginx-1.0.2>start nginx
或
C:\server\nginx-1.0.2>nginx.exe
注:建议使用第一种,第二种会使你的cmd窗口一直处于执行中,不能进行其他命令操作。
停止Nginx

2.2 Linux install Nginx

  1. Installation gcc gcc-c ++ (such as the new environment, and install, does not)

    $ yum install -y gcc gcc-c++
    
  2. Install wget

    $ yum -y install wget
    
  3. Installation PCRE library

    $ cd /usr/local/
    $ wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
    $ tar -zxvf pcre-8.33.tar.gz
    $ cd pcre-8.33
    $ ./configure
    $ make && make install
    #如果报错: 在 linux 中执行 wget 命令提示 -bash: wget: command not found 解决方法解决办法 yum -y install wget
  4. Install SSL libraries

    $ cd /usr/local/
    $ wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz
    $ tar -zxvf openssl-1.0.1j.tar.gz
    $ cd openssl-1.0.1j
    $ ./config
    $ make && make install
  5. Zlib installed inventory

    $ cd /usr/local/
    $ wget http://zlib.net/zlib-1.2.11.tar.gz
    $ tar -zxvf zlib-1.2.11.tar.gz
    $ cd zlib-1.2.11
    $ ./configure
    $ make && make install
  6. Install nginx

    $ cd /usr/local/
    $ wget http://nginx.org/download/nginx-1.8.0.tar.gz
    $ tar -zxvf nginx-1.8.0.tar.gz
    $ cd nginx-1.8.0
    $ ./configure
    $ make && make install
  7. Start nginx

    /usr/local/nginx/sbin/nginx
        ps -aux | grep 'nginx'
    

2.3 Mac use homebrew installation

  1. brew update // upgrade homebrew
  2. brew list // list brew installation package
  3. brew search nginx // search nginx
  4. brew info nginx // View details nginx, if not installed displays

    • Here you will see the following information

      15383227257572
      153832

    • We need to rely on openssl, pcre

  5. brew install nginx // install nginx

    15383226721637
    153832

  6. brew upgrade nginx // upgrade nginx

Three, nginx start to close

Refer to this blog

3.1 Restart

nginx -s reload  :修改配置后重新加载生效
nginx -s reopen  :重新打开日志文件   
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确

3.2 Close

nginx -s stop  :快速停止nginx
nginx -s quit  : 完整有序的停止nginx
 
其他的停止nginx 方式:

ps -ef | grep nginx
    
kill -QUIT 主进程号 :从容停止Nginx
kill -TERM 主进程号 :快速停止Nginx
pkill -9 nginx      :强制停止

Guess you like

Origin www.cnblogs.com/haoworld/p/nginx-jian-jie-yi-ji-an-zhuang-qi-dong-guan-bi.html