温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何使用Nginx

发布时间:2021-11-15 11:00:37 来源:亿速云 阅读:211 作者:iii 栏目:大数据

本篇内容介绍了“如何使用Nginx ”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

编译 Nginx

针对 Unix 环境

下载 Nginx

从 Nginx 官网 出下载想要编译版本的 Nginx,Nginx 官方提供三个版本:

  1. Mainline version

    主线版本,功能较新,稳定性较 Stable version 稍差,建议学习使用该版本,实际生产使用 Stable version。

  2. Stable version

    稳定版本

  3. Legacy versions

    历史版本

wget http://nginx.org/download/nginx-1.17.4.tar.gz
tar -zxvf nginx-1.17.4.tar.gz
cd nginx-1.17.4

Nginx 源码目录介绍

如何使用Nginx

auto

编译时的依赖库以及针对操作系统特性选择库

CHANGES

英文版 Nginx 各版本变更说明

CHANGES.ru

俄文版 Nginx 各版本变更说明(Nginx 作者是俄罗斯人)

conf

配置文件目录

configure

编译配置,编译前生成中间文件方便编译

主要有编译路径配置、某些功能开关及模块配置

--prefix 设置服务器存放地址,也是其他未配置路径的目录的默认根目录

--XXX-path 代表设置 XXX 目录的地址

--with-XXX_module 代表启用某些模块

--without-XX_module 代表禁用某些模块,这些模块时 Nginx 默认会编译的模块

还有一些其他参数可以参考可以参考 Ngxin 官方文档

contrib

vim 提示插件以及一些提升使用 Nginx 效率的工具脚本

如何使用Nginx

配置 vim 提示

cp -r contrib/vim ~/.vim

如何使用Nginx

针对不同层次结构以及不同关键字颜色区别会更明显

html

存放 index.html(Nginx 默认欢迎页)和 50x.html(Nginx 默认错误页)

index.html:

如何使用Nginx

50x.html:

如何使用Nginx

LICENSE

许可证信息

man

Nginx 为 linux 提供的帮助文件

可以使用命令查看(与编译后使用 nginx -h 相比内容更丰富)

man man/nginx.8

如何使用Nginx

README

自述文件

src

源码

编译

首先需要使用 configure 进行配置,一般只设置 --prefix 即可:

./configure --prefix=/home/sanchan/nginx

配置会输出配置简要说明:

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using system zlib library

  nginx path prefix: "/home/sanchan/nginx"
  nginx binary file: "/home/sanchan/nginx/sbin/nginx"
  nginx modules path: "/home/sanchan/nginx/modules"
  nginx configuration prefix: "/home/sanchan/nginx/conf"
  nginx configuration file: "/home/sanchan/nginx/conf/nginx.conf"
  nginx pid file: "/home/sanchan/nginx/logs/nginx.pid"
  nginx error log file: "/home/sanchan/nginx/logs/error.log"
  nginx http access log file: "/home/sanchan/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

配置生成的中间文件会放置到 objs目录下,有兴趣的小伙伴可以看下。

然后就可以进行编译了:

make

编译会在 objs 目录下生产 nginx 、nginx.8 及 ngx_modules.o,如果是升级 Nginx 可以将这些文件替换旧文件,如果是全新安装则执行:

make install

这样在之前配置的路径 /home/sanchan/nginx 中就可以看到 Nginx 相关文件了。

如何使用Nginx

sbin 为 Nginx 二进制执行文件目录

logs 为 Nginx 日志目录

conf 及 html 与下载的 Nginx 源码中目录是一致的

“如何使用Nginx ”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI