百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 技术资源 > 正文

yum安装nignx 添加模块_yum安装的步骤

off999 2025-02-21 14:49 53 浏览 0 评论

目前使用的nginx版本是1.20.1 , 在实现四层反向代理的时候用到stream模块

,但是检查配置的时候报错,没有stream模块,所以写此篇文章记录一下

[root@7-22 ~]# nginx -t
nginx: [emerg] unknown directive "stream" in /etc/nginx/nginx.conf:85
nginx: configuration file /etc/nginx/nginx.conf test failed

步骤一:首先查看自己nginx的版本,然后下载一个和自己版本一样的nginx tar包

[root@7-22 ~]# nginx -v
nginx version: nginx/1.20.1                //检查版本
[root@7-22 opt]# cd /opt && wget http://nginx.org/download/nginx-1.20.1.tar.gz 
   // 把tar包下在/opt 目录下 ,根据个人习惯调整目录
[root@7-22 opt]# tar zxvf nginx-1.20.1.tar.gz     //解压tar包

步骤二:备份原文件、安装依赖

[root@7-22 ~]# mv /usr/sbin/nginx /usr/sbin/nginx.bak
[root@7-22 ~]#  cp -r /etc/nginx  /etc/nginx.bak
[root@7-22 ~]# yum install -y perl-ExtUtils-Embed readline-devel zlib-devel pam-devel libxml2-devel libxslt-devel openldap-devel python-devel gcc-c++   openssl-devel cmakepcre-develnanowget  gcc gcc-c++ ncurses-devel per redhat-rpm-config.noarch

步骤三:进入解压的nginx目录里面,用./configure重新编译安装nginx

[root@7-22 nginx-1.20.1]# ./configure --prefix=/usr/share/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 --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-compat --with-debug --with-file-aio --with-google_perftools_module --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --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-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E' --with-stream 

报错解决:

1../configure: error: the HTTP image filter module requires the GD library.You can either do not enable the module or install the libraries.

yum -y install gd-devel

2../configure: error: the invalid value in --with-ld-opt="-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E"

yum -y install redhat-rpm-config.noarch

3../configure: error: perl module ExtUtils::Embed is required

yum -y install perl-devel perl-ExtUtils-Embed

4../configure: error: the Google perftools module requires the Google perftoolslibrary. You can either do not enable the module or install the library.

yum  -y install gperftools-devel

注意://解决完报错别忘了再重新编译,重新执行一遍步骤三

出现类似下面的命令说明编译没问题了

 + perl version: This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi
 + perl interpreter multiplicity found
checking for Google perftools ... found
creating objs/Makefile

Configuration summary
  + using threads
  + using system PCRE library
  + using system OpenSSL library
  + using system zlib library

  nginx path prefix: "/usr/share/nginx"
  nginx binary file: "/usr/sbin/nginx"
  nginx modules path: "/usr/lib64/nginx/modules"
  nginx configuration prefix: "/etc/nginx"
  nginx configuration file: "/etc/nginx/nginx.conf"
  nginx pid file: "/run/nginx.pid"
  nginx error log file: "/var/log/nginx/error.log"
  nginx http access log file: "/var/log/nginx/access.log"
  nginx http client request body temporary files: "/var/lib/nginx/tmp/client_body"
  nginx http proxy temporary files: "/var/lib/nginx/tmp/proxy"
  nginx http fastcgi temporary files: "/var/lib/nginx/tmp/fastcgi"
  nginx http uwsgi temporary files: "/var/lib/nginx/tmp/uwsgi"
  nginx http scgi temporary files: "/var/lib/nginx/tmp/scgi"

最后

[root@7-22 nginx-1.20.1]# make install     
[root@7-22 nginx-1.20.1]# nginx -t            //再次检查
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful    //可以看到,success


大功告成!!!

相关推荐

电脑怎么安装虚拟机教程(电脑如何安装虚拟机的视频教程)

答:笔记本电脑允许安装虚拟机的方法:1.在“虚拟机”窗口的工具栏中单击“创建虚拟机”命令,弹出“创建虚拟机”对话框,指定该虚拟机的名称和位置;2.进入“指定内存和网络选项”对话框,建议在内存中设置大于...

手机桌面动态壁纸(手机桌面动态壁纸动漫)

打开手机来到手机桌面,长按手机桌面的空白处,会跳出对桌面的设置。2.在跳出的功能选项中选择第一个壁纸,对手机壁纸进行一系列的设置。3.选择壁纸之后再跳出来的设置中选择滚动,这样的话壁纸就能谁让你手划而...

xp装win7双系统怎么设置(xp系统怎么装双系统)

设置U盘为第一启动项并进入PE系统。开机按F2进入BOIS,在BOOT选项中将U盘设为第一启动盘,通过按F6(有的是Shift+)调整顺序。(或开机按ESC选择启动盘,即你的U盘)。按F10保存...

系统之家u盘装系统工具(系统之家u盘安装系统步骤win7)

系统之家下的系统用U盘安装的方法:1、首先,关闭所有的杀毒软件。?2、进入工具后,在最上方选择U盘启动,进入U盘启动盘制作界面。?3、保留默认格式和分区格式,无需手动更改。点击开始制作。?4、工具会自...

服务器系统有哪几种(服务器系统叫什么名字)
服务器系统有哪几种(服务器系统叫什么名字)

服务器系统主要分为四大流派:LINUX、WINDOWS、NETWARE、UNIX。服务器系统通常来讲是指安装在服务器上的操作系统。比如安装在Web服务器、应用服务器和数据库服务器等上的操作系统,是企业IT系统的基础架构平台,也是按应用领域划...

2025-12-22 04:03 off999

msdn重装系统(msdn重装win10)

笔记本一般都是家庭版正版,就下载第二个消费者版本然后选择《家庭版》,如果不对应安装就会提示需要激活!如果使用工具激活了,以后你机器自带的正版系统也就没有了。1.建议先安装驱动。2.因为安装驱动可以...

修复磁盘能不能中途取消(修复磁盘能不能中途取消掉)

修复磁盘可以原则上建议等待,一般情况下10分钟左右磁盘就会检测完毕。但如果超过10分钟,就不建议等待了,这种情况基本都是硬盘有逻辑坏道或者物理坏道,基本都是非正常关机造成的。所以,可以使用PE系统进行...

数据库系统工程师(数据库系统)

1相对来说比较难考2因为数据库系统工程师需要掌握大量的数据库理论知识、数据库设计和管理技能、数据分析和优化能力等多方面的技能,考试难度较大。3但是只要有足够的学习时间和精力,通过系统学习和练习,...

u盘安装win7系统到固态(u盘安装系统到固态硬盘)

1.进入bios设置,查看你的本本是否可以直接设置硬盘顺序。可以的话设置下,然后固态硬盘安装win7即可。2.接硬盘数据线注意顺序,固态硬盘接前面,数值小的端口。根据你的情况如果接口一样,可以交换2条...

优盘启动盘重装系统进入bios

原因分析:开机时直接进入BIOS的主要原因是主办BIOS的设置出现了问题。有些电脑的主板在设置的时候为了能够更加人性化所以加入了许多其他的功能。当BIOS的设置不正确时重启电脑就会自动进入BIOS。解...

台式电脑怎么调节亮度快捷键
  • 台式电脑怎么调节亮度快捷键
  • 台式电脑怎么调节亮度快捷键
  • 台式电脑怎么调节亮度快捷键
  • 台式电脑怎么调节亮度快捷键
usb系统盘下载(系统u盘之家)

手机不可以下载电脑系统到U盘里,这是跟系统文件的格式有直接关系。电脑的系统文件,它在下载安装的时候必须使用电脑版本的U盘才可以正确安装。手机的版本它和电脑的版本差别比较大,即使下载后也不可能正确安装。...

windows8模拟器(国内版)(win8模拟器安卓版下载)

雷电模拟器能在win8系统运行,1、官网下载雷电模拟器,双击安装包进入安装界面。2、点击“自定义安装”修改安装路径,点击“浏览”选择好要安装的路径,默认勾选“已同意”,最后点击“立即安装”。...

win10安装专业版还是家庭版(win10安装专业版还是家庭版好)

从Win10家庭版和专业版对比来看,Win10专业版要比家庭版功能更强大一些,不过价格更贵。另外Win10专业版的一系列Win10增强技术对于普通用户也基本用不到,多了也显得系统不那么精简,因此普通个...

win10系统保护不见了(win10系统保护打不开怎么办)

1、启动计算机,启动到Windows10开机LOGO时就按住电源键强制关机,重复强制关机3次!2、重复步骤3次左右启动后出现“自动修复”界面,我们点击高级选项进入;3、接下来会到选择一个选项界面...

取消回复欢迎 发表评论: