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

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

off999 2025-02-21 14:49 58 浏览 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、把错误驱动删掉如果你安...

电脑开机弹出系统恢复选项(电脑开机经常出现系统恢复界面)

  这种情况一般都是系统引导出现问题,可以【F8】选择【最后一次正确配置】,重启后一般都能恢复;如果不行可以选择进入【安全模式】【恢复我的计算机到一个较早的时间】。以下是详细介绍:  1、开机时多次点...

手机版电脑模拟器下载(手机电脑模拟器下载的文件在哪)
手机版电脑模拟器下载(手机电脑模拟器下载的文件在哪)

  玩家们想要在电脑上畅快地玩真实手机,首先就需要先下载它的电脑版模拟器啦。在这里推荐大家使用的是电脑安卓模拟器,这是一款十分流畅好用的真实手机安卓模拟器,性能强悍,功能完备。  1、下载完真实手机安卓模拟器。  2、在电脑上进行安装,双击...

2026-01-01 16:03 off999

下载计算机到手机(手机下载计算机怎么下载)
  • 下载计算机到手机(手机下载计算机怎么下载)
  • 下载计算机到手机(手机下载计算机怎么下载)
  • 下载计算机到手机(手机下载计算机怎么下载)
  • 下载计算机到手机(手机下载计算机怎么下载)
u盘启动不了怎么回事(u盘启动也启动不了)

原因三:USB传输性能不佳导致;解决三:换个USB插口试试,建议将u盘插入到电脑机箱后置的USB插口处。原因四:u盘自身的质量问题导致;解决四:换一个u盘制作试一试。原因五:电脑系统问题导致;解决五:...

联想笔记本电脑键盘输入没反应

1.首先在可以进行输入的位置,长按下某个按键1秒以上,看看有没有反应。有反应看第2,没反应看第3。2.控制面板~轻松使用~轻松使用设置中心~更改键盘的工作方式~取消筛选键并应用即可。3.打开设备管理器...

软件管家电脑版下载官网(软件管家电脑版下载官网安装)

要下载和安装应用程序,您可以按照以下步骤使用电脑管家:1.打开电脑管家应用程序。2.在主界面上,您可以找到一个名为“应用中心”的选项,点击它。3.在应用中心中,您可以浏览各种应用程序的列表。您可...

台式电脑怎么取消定时关机(台式电脑设置自动关机怎么取消)

电脑设置了每天定时关机,取消的方法有多种,以下提供三种方式:方法一:打开任务计划程序(TaskScheduler)。找到“任务计划程序库”(TaskSchedulerLibrary),找到设置的...

win7怎么截屏快捷键(win7怎样截屏快捷键)

在Win7系统中,自带的截图快捷键是“PrtScn”键,即PrintScreen键。按下这个键后,系统会将当前屏幕的内容复制到剪贴板中,然后用户可以将其粘贴到其他应用程序中进行编辑或保存。此外,Wi...

如何查看笔记本配置(如何查看笔记本配置高低)

两种方法一种你在笔记本背面有个ID号,也就是序列号,你把它抄下来,输到笔记本品牌的官网上,查看他的配置就可以,这是第1种方法,第2种方法,你开机后,我的电脑上单击右键,点属性,就会在出来你的CPU内存...

linux软件(linux软件图标)

Linux是一种自由和开放源代码的类UNIX操作系统。该操作系统的内核由林纳斯·托瓦兹在1991年10月5日首次发布。在加上用户空间的应用程序之后,成为Linux操作系统。Linux也是自由软件和开放...

hp laserjet p1108打印机驱动

惠普LaserJetProP1108打印机安装打印机驱动的方法,可以通过以下步骤操作来实现:1、运行驱动安装包,在“HPLaserJetProP1100打印机系列”下,点击“USB安装...

台式机最好的配置(台式机最强配置)

家用台式电脑cpu一般选择英特尔8-10代的i3就能满足正常的家用,内存方面选择16g,绝对够用,再选择一块512g的固态硬盘,保证电脑的速度2022年台式电脑建议你可以配16gb或32gb的内存。硬...

笔记本电脑home键在哪(笔记本的home键怎么用)

home键位置一般有三个:一、键就在键盘最右边一列的上方,也是右上角处。二、在数字键盘的“7”键上,如果想使用"home"键功能,需要先关闭数字键功能。一般笔记本开、关数字键功能是按F...

win7汉化包下载(win7系统汉化)

要下载犀牛7grasshopper汉化包,首先你需要从官方网站或可靠的第三方网站上找到可信赖的下载链接。然后,点击链接进行下载,并确保你的电脑设备有足够的存储空间来安装这个汉化包。安装完成后,打开犀牛...

取消回复欢迎 发表评论: