Nginx的安装

218 阅读1分钟

一、 What's Nginx?

Nginx [engine x] is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server.

二、How to install?

准备工作:

  1. 系统:ubuntu16.04 server
  2. 网络:畅通
  3. 方式:通过deb包安装
  4. 其他Linux平台安装方式参考:install nginx

安装过程(本教程是root用户执行命令,其他用户需在各个命令前加 sudo)

  1. wget -c https://nginx.org/keys/nginx_signing.key
  2. sudo apt-key add nginx_signing.key
  3. echo 'deb http://nginx.org/packages/ubuntu/ xenial nginx' >> /etc/apt/sources.list
  4. echo 'deb-src http://nginx.org/packages/ubuntu/ xenial nginx' >> /etc/apt/sources.list
  5. apt update
  6. apt install nginx
  7. nginx # 启动nginx

三、How to use Nginx?

  • nginx -s signal

Where signal may be one of the following:

  • stop — fast shutdown
  • quit — graceful shutdown
  • reload — reloading the configuration file
  • reopen — reopening the log files

For Example:

  1. nginx -s quit
  2. nginx -s reload
  3. nginx -s restart

if the master process ID is 1628, to send the QUIT signal resulting in nginx’s graceful shutdown, execute:

kill -s QUIT 1628

For getting the list of all running nginx processes, the ps utility may be used, for example, in the following way:

ps -ax | grep nginx