栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Nginx 源码包安装部署

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Nginx 源码包安装部署

Nginx

轻量级 支持高并发web服务器 开启安装很快    

默认centos 系统不包括nginx rpm包 不能直接用 yum直接安装 需要epel.repo支持

源码包安装

[root@localhost ~]# tar xf nginx-1.16.1.tar.gz -C /usr/src/

[root@localhost ~]# cd /usr/src/nginx-1.16.1/

[root@localhost nginx-1.16.1]# ls

auto     CHANGES.ru  configure  html     man     src

CHANGES  conf        contrib    LICENSE  README

[root@localhost nginx-1.16.1]# ./configure –help

Nginx安装过程需要有依赖

[root@localhost nginx-1.16.1]# yum -y isntall zlib-devel gcc gcc-c++ make pcre-devel

Zzw

Zzw

创建一个程序用户

[root@localhost nginx-1.16.1]# useradd -M -s /sbin/nologin nginx

[root@localhost nginx-1.16.1]# ./configure --prefix=/usr/local/nginx-1.16 --user=nginx --group=nginx --with-http_stub_status_module

[root@localhost nginx-1.16.1]# make && make install

[root@localhost nginx-1.16.1]# cd /usr/local/nginx-1.16/

[root@localhost nginx-1.16]# ls

conf  html  logs  sbin

[root@localhost nginx-1.16]# cd sbin/

[root@localhost sbin]# ls

nginx

[root@localhost sbin]# ./nginx

[root@localhost sbin]# ss -anput | grep :80

tcp    LISTEN     0      128       *:80                    *:*                   users:(("nginx",pid=34341,fd=6),("nginx",pid=34340,fd=6))

启动成功去浏览器访问192.168.200.111:80  出现如下界面则开启成功

  1. tar xf nginx-6….gz -C /usr/src
  2. cd /usr/src/nginx-1.6…/

Nginx是一个模块化的软件  ./configure –help

Nginx 和apache io  模型区别 select 使用线性扫描进行轮询最多可监听1024个文件描述符效率有点低对文件描述符有限制(一个一个处理) epoll通过状态码来判断如何处理(异步) poll 和select相似

Nginx 默认使用epoll   可以在编译时指定

从源码包编译

  • --prefix=path 定义安装路径
  • --sbin-path=path 定义可执行文件安装路径
  • --conf-path=path 定义配置文件路径
  • --pid-path=path  定义nginx.pid文件路径
  • --error-log-path=path 定义错误日志文件路径
  • --http-log-path=path 定义访问日志文件路径
  • --build=name — sets an optional nginx build name.设置一个可选的Nginx建立名称
  • --user=name  设置默认用户为 nobody.
  • --group=name 设置默认组
  • --with-select_module或--without-select_module  
  • 允许或禁止编译服务器使用select()方法工作。如果平台上没有合适的方法找到,例如kqueue,epoll,或者/dev/poll,那么这个模块会自动编译。
  • --with-poll_module或--without-poll_module  
  • 允许或禁止服务器工作在poll()方式。如果平台上没有合适的方法像kqueue,epoll或者/dev/poll,那么这个模块会自动编译。
  • poll和select实现功能差不多,但poll效率高,以后要多用poll
  • --without-http_gzip_module 禁止编译压缩HTTP服务器回复的模块。要想编译和运行这么模块,那么需要zlib库的支持。
  • --without-http_rewrite_module 禁止编译HTTP重定向请求的模块。为了编译这个模块,PCRE库需要事先准备好。
  • --without-http_proxy_module 禁止编译HTTP服务器代理模块
  • --with-http_ssl_module 允许编译支持HTTPS协议的模块。默认没编译。为了编译和运行这个模块,OpenSSL库是需要的。
  • --with-pcre=path 指定pcre库的位置
  • --with-pcre-jit  构建带有“just-in-time compilation(运行时编译执行的技术)”的pcre库,支持 (1.1.12, the pcre_jit directive).
  • --with-zlib=path 指定zlib库的位置
  • --with-cc-opt=parameters — sets additional parameters that will be added to the CFLAGS variable. When using the system PCRE library under FreeBSD, --with-cc-opt="-I /usr/local/include" should be specified. If the number of files supported by select() needs to be increased it can also be specified here such as this: --with-cc-opt="-D FD_SETSIZE=2048".
  • --with-ld-opt=parameters 设置在链接时候的额外的参数 (When using the system PCRE library under FreeBSD, --with-ld-opt="-L /usr/local/lib" should be specified.)

[root@localhost nginx-1.16]# ls

client_body_temp  conf  fastcgi_temp  html  logs  proxy_temp  sbin  scgi_temp  uwsgi_temp

启动时加载的临时文件

Scgi通用网关接口

Fastcgi 快速网关接口 php 搭配使用

Uwsgi               python

[root@localhost ~]# hostname linux

[root@localhost ~]# bash

[root@linux ~]# ps -aux | grep nginx

root      34340  0.0  0.0  20560   612 ?        Ss   10:12   0:00 nginx: master process ./nginx

nginx     34341  0.0  0.1  21012  1548 ?        S    10:12   0:00 nginx: worker process

root      34501  0.0  0.0 112824   984 pts/1    R+   10:26   0:00 grep --color=auto nginx

[root@linux conf]# echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

[root@linux conf]# which ls

alias ls='ls --color=auto'

       /usr/bin/ls

[root@linux conf]# ln -s /usr/local/nginx-1.16/sbin/nginx /usr/local/sbin/

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/310860.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号