2019独角兽企业重金招聘Python工程师标准>>>

一些准备工作,常见问题

简介

Nginx (engine x) 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器,其将源代码以类BSD许可证的形式发布。现在Nginx已经成为一家拥有各种产品的公司,包括Nginx Plus、Nginx Ctroller、 Nginx Unit、 Nginx Amplify、 Nginx WAF.但是Nginx仍然是开源。整个系列都会依托开源的版本,简称Nginx

安装

两类安装,官方编译好的安装包直接通过源安装即可,二是通过源码包编译安装。 编译好的安装包已经加入依赖关系解决,不用用户自己处理依赖不存在对的情况。源码包安装提供更高的定制性,可最大化性能或功能。

官方编译好的安装包 这里我们使用centos6.x系统

[root@slave2 ~]# vim /etc/yum.repos.d/nginx.repo
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1[root@slave2 ~]# yum  install  nginx -y
Installed:nginx.x86_64 0:1.12.2-1.el6.ngx
Complete![root@slave2 ~]# nginx
nginx        nginx-debug[root@slave2 ~]# which nginx
/usr/sbin/nginx
[root@slave2 ~]# which nginx-debug
/usr/sbin/nginx-debug
[root@slave2 ~]#  /usr/sbin/nginx -V
nginx version: nginx/1.12.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
[root@slave2 ~]#  /usr/sbin/nginx-debug -V
nginx version: nginx/1.12.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' --with-debug

nginx安装后加入nginx和nginx-debug命令,nginx-debug比nginx编译参数多了--with-debug开启了debug日志,这在调试nginx时十分有用,但开启后会严重限制nginx的并发数。

编译安装

[root@slave2 ~]# wget http://nginx.org/download/nginx-1.12.2.tar.gz
[root@slave2 ~]# tar -zxvf nginx-1.12.2.tar.gz
[root@slave2 ~]# cd nginx-1.12.2
[root@slave2 nginx-1.12.2]# ./configure --prefix=/opt/nginx-1.12.2 --with-debug
[root@slave2 nginx-1.12.2]# make -j2
[root@slave2 nginx-1.12.2]# make install

源码包需要自己解决依赖关系~~

管理nginx

安装包

[root@slave2 ~]# /etc/init.d/nginx start
Starting nginx:                                            [  OK  ]
[root@slave2 ~]# /etc/init.d/nginx reload
Starting nginx:                                            [  OK  ]
[root@slave2 ~]# /etc/init.d/nginx stop
Stopping nginx:                                            [  OK  ]

debug版本

[root@slave2 ~]# /etc/init.d/nginx-debug start
Starting nginx:                                            [  OK  ]
[root@slave2 ~]# /etc/init.d/nginx-debug reload
Starting nginx:                                            [  OK  ]
[root@slave2 ~]# /etc/init.d/nginx-debug stop
Stopping nginx:                                            [  OK  ]

源码包

[root@slave2 ~]# /opt/nginx-1.12.2/sbin/nginx
[root@slave2 ~]# /opt/nginx-1.12.2/sbin/nginx -s reload
[root@slave2 ~]# /opt/nginx-1.12.2/sbin/nginx -s stop
[root@slave2 ~]# /opt/nginx-1.12.2/sbin/nginx -t
nginx: the configuration file /opt/nginx-1.12.2/conf/nginx.conf syntax is ok
nginx: configuration file /opt/nginx-1.12.2/conf/nginx.conf test is successful

测试

[root@slave2 ~]# curl localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>body {width: 35em;margin: 0 auto;font-family: Tahoma, Verdana, Arial, sans-serif;}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

默认nginx监听在localhost上,通过curl访问成功。 nginx已经安装成功。如果提示如下,请检查防火墙是否开放80端口访问。

[root@slave2 ~]# curl localhost
curl: (7) couldn't connect to host

转载于:https://my.oschina.net/monkeyzhu/blog/1649573

nginx 如何处理请求系列1-Nginx安装相关推荐

  1. nginx 如何处理请求系列3-server_name指令

    2019独角兽企业重金招聘Python工程师标准>>> 当Nginx收到请求后,Nginx分成两部分进行,包括server_name和URL,首先Nginx通过server_name ...

  2. nginx怎么处理php,nginx如何处理请求

    当请求到达nginx服务器之时 如果我们配置文件如下:server { listen 80; server_name example.org www.example.org; ... } server ...

  3. nginx限制请求之一:(ngx_http_limit_conn_module)模块

    相关文章: <高可用服务设计之二:Rate limiting 限流与降级> <nginx限制请求之一:(ngx_http_limit_conn_module)模块> <n ...

  4. nginx限制请求之四:目录进行IP限制

    相关文章: <高可用服务设计之二:Rate limiting 限流与降级> <nginx限制请求之一:(ngx_http_limit_conn_module)模块> <n ...

  5. Docker系列三~docker安装nginx

    Docker系列三 docker安装nginx 搜索nginx版本 docker search nginx 拉取nginx最新版本镜像 docker pull nginx:latest 查看本地镜像 ...

  6. Docker系列 二. Docker 安装 Nginx

    Docker 安装 Nginx Nginx 是一个高性能的 HTTP 和反向代理 web 服务器,同时也提供了 IMAP/POP3/SMTP 服务 . 1.查看可用的 Nginx 版本 访问 Ngin ...

  7. nginx 一个请求发给多台机器_Nginx系列二:负载均衡与反向代理

    一.负载均衡 1.什么是负载均衡 随着请求数的快速增长,单服务器已经无法承担大量用户的并发访问,这个时候,就需要建立服务器集群,来让多台服务器协同工作,提高整体项目的吞吐量和QPS.假设一台设备资源占 ...

  8. nginx学习笔记(7)Nginx如何处理一个请求---转载

    如何防止处理未定义主机名的请求 基于域名和IP混合的虚拟主机 一个简单PHP站点配置 基于名字的虚拟主机 Nginx首先选定由哪一个虚拟主机来处理请求.让我们从一个简单的配置(其中全部3个虚拟主机都在 ...

  9. linux nginx 代理iis,nginx 系列 linux下安装以及配置IIS分发

    一. 安装 操作系统:centos 7 ,nginx版本1.12.2,windows server 2008 iis 1.1 确认nginx所依赖的工具 Zlib:  nginx提供gzip模块,需要 ...

最新文章

  1. 《LeetCode力扣练习》第46题 全排列 Java
  2. 剪我一根头发,就要做我一天女人。
  3. C++中namespace的理解与实践
  4. HDU - 1907 John(尼姆博弈变形)
  5. android应用启动页面显示不出来了,Android应用中启动页出现白屏如何解决
  6. 【ArcGIS遇上Python】ArcGIS Python获取Shapefile矢量数据字段名称
  7. SQL Server 2008存储结构之GAM、SGAM
  8. gfirefly 框架分析
  9. TortoiseGit使用入门
  10. python3文档字符串_python3基础:字符串、文本文件
  11. C++之const类成员变量,const成员函数
  12. 强悍的 ubuntu —— 窗口界面管理与设置
  13. 【网络文件共享】04、rsync基础
  14. matlab保存矩阵为txt,matlab保存矩阵成txt
  15. 怎么将文档存在计算机中,电脑中如何将多个文本文档内容合并在一个文本文档中...
  16. 《Go语言实战》读书笔记——关于Go语言的介绍
  17. 【vue手写图片预览组件】在vue2.0项目中手写图片预览组件,旋转、放大、滚动、下载等功能
  18. 2022暑期牛客多校训练第5场 A.Don‘t Starve
  19. 基于java+mysql的Swing+MySQL图书管理系统(java+swing+gui+mysql)
  20. python 将List中元素两两组合

热门文章

  1. java 全局变量_Javascript中的局部变量、全局变量的详解与var、let的使用区别
  2. 基础的VueJS面试题(附答案)
  3. 【TypeScript】do...while 循环
  4. android瓦片地图下载,Andorid 如何加载 瓦片地图
  5. macos自带java_在 MacOS 上安装 Java - Java 入门教程
  6. linux切换软件版本,Linux中dpkg工具update-alternatives实现符号链接软件版本的切换(转)...
  7. C++ exception
  8. 第五天2017/04/06(下午1:C、C++混合编程 与 #ifdef __cplusplus extern C{ })
  9. 【Linux】39.nslookup查看域名与其对应的ip
  10. 谷歌OKR指导手册 (译)