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

nginx是一个http和反转代理服务器,还可以用作邮件代理,TCP/UDP代理服务器。

nginx has one master process and several worker processes. The main purpose of the master process is to read and evaluate configuration, and maintain worker processes. Worker processes do actual processing of requests. nginx employs event-based model and OS-dependent mechanisms to efficiently distribute requests among worker processes. The number of worker processes is defined in the configuration file and may be fixed for a given configuration or automatically adjusted to the number of available CPU cores

Window平台下(如果linux下将nginx当成一个应用使用的话,用法和window平台下差不多,如果在linux系统上作为服务使用,则区别较大):

下载安装

window平台下,下载nginx-1.15.12的压缩包,解压即可。

使用

windows平台下,在解压目录下,启动命令

start nginx

启动tasklist命令行工具包来查看进程

tasklist /fi "imagename eq nginx.exe"

其他命令

nginx/Windows runs as a standard console application (not a service), and it can be managed using the following commands:

  • nginx -s stop         fast shutdown
  • nginx -s quit          graceful shutdown,This command should be executed under the same user that started nginx
  • nginx -s reload      changing configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processes
  • nginx -s reopen     re-opening log files

nginx的配置文件在 ./conf/nginx.conf 中,Configuration File文件的结构:

nginx consists of modules which are controlled by directives specified in the configuration file. Directives are divided into simple directives and block directives. A simple directive consists of the name and parameters separated by spaces and ends with a semicolon (;). A block directive has the same structure as a simple directive, but instead of the semicolon it ends with a set of additional instructions surrounded by braces ({ and }). If a block directive can have other directives inside braces, it is called a context (examples: eventshttp,server, and location).

Directives placed in the configuration file outside of any contexts are considered to be in the main context. The events and http directives reside in the main context, server in http, and location in server.

The rest of a line after the # sign is considered a comment.

Linux平台下(以Centos为例,此时nginx是作为一项服务):

安装

yum install epel-release

yum install nginx

服务的管理 开启 查询 停止 重启

systemctl start nginx

systemctl status nginx

systemctl stop nginx

systemctl restart nginx 

重新载入nginx的配置文件(在修改配置文件之后)

systemctl reload nginx

nginx的主要配置文件在 /etc/nginx

核心配置文件是 /etc/nginx/nginx.conf

日志文件是在 /var/log/nginx

上面都是直接使用安装包,如果对ngnix有较高的定制需求,需要自己编译打包,还可以下载丰富的第三方插件。

参考:

http://nginx.org/en/docs/beginners_guide.html

https://linuxize.com/post/how-to-install-nginx-on-centos-7/

End

最新文章

  1. VUE 入门基础(3)
  2. golang的json操作
  3. c# XML序列化与反序列化
  4. dp--poj1458最长公共子序列
  5. xcode 把cocos2d-x 以源码的形式包含进自己的项目适合, 性能分析问题的错误
  6. uva-12657 - Boxes in a Line(双向链表)
  7. Unity 3D使用GameObject创建一个简单的可移动物体
  8. WCF(一)基础整理
  9. gulp实现公共html代码复用
  10. 手把手教你从零开始搭建SpringBoot后端项目框架
  11. Forget Guava: 5 Google Libraries Java Developers Should Know
  12. spring boot 集成disconf
  13. Failed to connect to /127.0.0.1:8080
  14. Gitlab备份和恢复操作记录
  15. 全网最详细的hive-site.xml配置文件里如何添加达到Hive与HBase的集成,即Hive通过这些参数去连接HBase(图文详解)
  16. 关于运行“基于极限学习机ELM的人脸识别程序”代码犯下的一些错误
  17. Xcode解决“Implicit declaration of function 'XXX' is invalid in C99” 警告或报错
  18. QMainWindow + QtabWidget 实现 菜单栏 和 标签
  19. mysql 索引使用策略及优化
  20. 通过jquery.validate.js校验表单字段是否合法

热门文章

  1. C++_数字时钟
  2. JUnit4源码学习笔记
  3. pgadmin连接 postgresql远程设置
  4. eclipse中的javaEE插件
  5. php+mysql 原生事务回滚
  6. Android中 Git 使用中几个概念
  7. StreamReader和StreamWriter说明
  8. java.lang.RuntimeException: Class "org.apache.maven.cli.MavenCli$CliRequest" not found
  9. php用PDO查询mysql数据库结果中文乱码
  10. 微信小程序开发——使用mock数据模拟api请求