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

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

off999 2025-02-21 14:49 69 浏览 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


大功告成!!!

相关推荐

如何重装系统win7视频教程(如何重装系统win7具体步骤)

不需要重装知识点延伸,更换CPU-BIOS设置1)未更改过bios设置,确认主板支持cpu型号直接插上即可,bios会自适应2)之前更改过bios设置,在更换cpu之前应需要将bios恢复出厂...

惠普售后维修官网电话(惠普官网维修中心电话)

要找到惠普的售后服务,你可以通过以下几种方式进行联系。首先,你可以访问惠普的官方网站,在网站上找到售后服务的相关信息,包括联系电话和在线支持。其次,你可以拨打惠普的客户服务热线,向客服人员咨询并安排售...

笔记本迈克菲怎么卸载(笔记本迈克菲怎么卸载不了)

戴尔笔记本电脑上的迈克菲中心可以卸载,迈克菲中心为一款杀毒软件,如果自身笔记本电脑不需要可以进行卸载。迈克菲中心卸载步骤:1、打开桌面“此电脑”。2、在“此电脑”界面中点击选择“卸载或更改程序”。3、...

windows10怎么进入修复模式(win10如何进入修复系统)

1、 进入WindowsRE恢复模式。非正常启动三次,可进入WindowsRE恢复模式。具体操作方法如下:按住电源按钮10秒钟以关闭设备。再次按电源按钮以打开设备。看到Windo...

现在哪个浏览器好用(现在哪种浏览器好用)

一、谷歌浏览器谷歌浏览器是公认最好用的,这个可以从市场占有率看出端倪,超过三分之二的用户使用谷歌浏览器。Chrome浏览器以简洁快速著称,不管是普通用户还是开发人员,chrome浏览器都是首选。Chr...

笔记本电脑怎么恢复出厂设置联想
  • 笔记本电脑怎么恢复出厂设置联想
  • 笔记本电脑怎么恢复出厂设置联想
  • 笔记本电脑怎么恢复出厂设置联想
  • 笔记本电脑怎么恢复出厂设置联想
win10系统还是win7系统好(是win10好还是win7好)

就我个人觉得win7系统和win10系统都挺好用的,主要看个人习惯,win10系统也推出了3年了,相信很多用户也已经尝试过win10系统,操作上没有什么很大的区别,就是界面有些不同,这就看个人喜欢了。...

重装系统u盘制作教程(重装系统u盘怎么制作)

以下是重装电脑系统的一般步骤:在正常可用的电脑上下载并安装一个制作启动U盘的工具,例如Rufus、WinToUSB等。使用该工具将操作系统安装文件写入U盘,并设置U盘为启动盘。将U盘插入需要重装系统的...

从win8装回win7系统(win8.1怎么装回win7)

重装电脑,而且您的【电脑系统没有完全崩溃】,那么可以用【【【硬盘安装系统的方法】】】来装系统,无需借助光盘或者u盘,简单快速。电脑硬盘安装系统的方法如下:1.到WIN7旗舰版基地去http://ww...

查看电脑硬件信息的4个技巧

1、点击下面任务栏中的windows图标或按键盘windows键打开开始菜单。2、在开始菜单中找到设置或settings,通常是右上角的齿轮按钮。3、然后在设置界面中找到system选项,点击进入。4...

老式电脑的显卡在哪里(老式电脑主机显卡在哪)

十年前的老电脑没必要了,换新吧,估计接口什么也都有限制了我看了下你这个是品牌电脑,代工板的应该是没有显卡插槽的,有的话也是AGP的,可以去淘片AGPATI9000系列的卡或者6200660...

word产品密钥2016(word产品密匙2016)

word2016激活密钥有两种类型:永久激活码和KMS期限激活密钥。其中,永久激活密钥可以使用批量授权版永久激活密钥进行激活,如所示;而KMS期限激活密钥需要使用KMS客户端密钥进行激活,如所示。另外...

如何选择电脑配置(如何选择电脑配置的高低)

选择电脑配置时,首先要考虑自己的需求和预算。确定用途(如游戏、办公、设计等),然后选择适合的处理器、内存、显卡、存储和显示器等。处理器要根据性能和功耗进行选择,内存要足够大以支持多任务处理,显卡要根据...

win10下方任务栏无反应(win10下方任务栏消失)

按ctrl+alt+delete键win10系统电脑中,按键盘上的ctrl+alt+delete键2点击任务管理器点击出现窗口选项中的“任务管理器”3点击重新启动打开管理器后,右击Windows资源管...

win11找不到wifi网络(win11找不到wifi网络图标)

原因:可能是缺少了无线网卡驱动。解决方法:1、打开开始菜单,在上方搜索并进入“设备管理器”。2、接着展开网络适配器,找到无线网卡设备,右键选中,点击“更新驱动程序”。3、最后选择“自动搜索驱动程序”,...

取消回复欢迎 发表评论: