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

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

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


大功告成!!!

相关推荐

bios硬盘启动项是哪个(电脑bios硬盘启动)

1、开机按F2(具体按键看开机屏幕提示)进入BIOS系统,打开Boot选项卡;2、在Boot页面下找到IDE1,一般这个表示的就是电脑硬盘,按键盘上的F6将该启动项向上移至第一位,也就是将硬盘设为第一...

虚拟机ubuntu安装教程(ubuntu 虚拟机安装)

在虚拟机Ubuntu下安装MATLAB的步骤如下:1.下载MATLAB安装包:访问MATLAB官网,选择适合你的Ubuntu版本的MATLAB安装包,并下载到本地计算机。2.安装虚拟机软件:在Ub...

bootmgrismissing开机不了怎么办

你是不是没打全?大概意思就是启动的东西缺失!重装系统或者是补充装修复系统引导bootmgr丢失无法开机的解决方法:1、重新启动计算机,如果遇到“BOOTMGRismissing”错误,可以尝试的第...

手机上怎么改路由器密码(手机上怎么改路由器密码wifi密码)

输入地址打开手机浏览器后在地址栏输入路由器地址,打开路由器登录界面。2/4点击常用设置输入路由器管理员密码后进入路由器主界面,点击上方的常用设置。3/4找到密码在窗口中分别找到2.4G和5Gwifi...

windowsserver2016(windowsserver2016激活密钥)

WindowsServer2016代表着微软发布的一款服务器操作系统。它是2016年推出的,为企业提供了强大的功能和稳定性,支持大规模的数据中心和云计算环境。WindowsServer2016...

联想手机官网查询真伪入口(联想手机正品查询)

官方查询页面http://support1.lenovo.com.cn/lenovo/wsi/我认为联想本本一旦出厂就自然就可以查询号码了。因为我们单位订购的一批联想本本,直接从上海生产基地把本本...

中国电信官方测网速(网络测速 中国电信)

你好,你可以下载一个第三方软件进行测速,如果你手机自带测速软件直接可以测速的,也可以下载电信测速软件。1.进入中国电信官方测速网站。  说明:中国电信宽带测速是根据网络行业网速标准制定的专业测速工具,...

sony官网中国官方网站(索尼官方app下载安装)

网址是https://www.sony.com.cn/索尼的中文官网不仅可以有售后服务等信息,也会有新品发布消息。对于索尼的粉丝来说,官网是必不可少的。您可以按照以下步骤在索尼官网上查找产品的序列号:...

路由器登陆账号密码(路由器登陆账号密码忘了)

1、一般路由器的账号为admin,密码也是admin;还有路由器产品出厂时默认登录密码是guest,有点路由器产品的出厂时初始登录密码为【空】,也就是没有登录密码,直接就可以进入设置界面的;  2、您...

新风系统安装步骤(新风系统安装方案图)

1.设计与规划:在安装新风系统之前,首先需要进行设计和规划。根据建筑物的空间布局、通风需求、使用人数等因素,确定新风系统的类型(如全热交换新风系统、单向流新风系统等)和安装位置。2.现场勘查:在设...

系统win8下载(win8下载软件)

可以按照以下步骤在Win8上下载和安装Word:1.通过微软官网下载购买,或者通过MicrosoftStore应用商店进行购买和下载。2.下载完成后,打开文件夹,双击setup进行安装。3.安...

电脑的详细参数在哪里看(电脑详细参数怎么看)

要查看电脑参数,可以通过以下几种方式:1.使用操作系统提供的系统信息工具:大多数操作系统都会提供一个系统信息工具,可以显示电脑的基本参数。在Windows操作系统中,可以打开"控制面板...

windows无法连接打印机拒绝访问
  • windows无法连接打印机拒绝访问
  • windows无法连接打印机拒绝访问
  • windows无法连接打印机拒绝访问
  • windows无法连接打印机拒绝访问
oppo解除安全模式(oppp取消安全模式)

一般来说,关机重启手机即可退出安全模式。如果重启手机安全模式还没有解除的话,可以使用手机杀毒软件对手机进行全盘查杀,杀完毒再进行重启试试。如果还是不行的话,那就只能备份手机里的重要数据,刷机或者恢复出...

电脑更新后无法正常启动(电脑更新后无法正常使用)

电脑更新无法开机可能有多种原因。首先,可能是由于更新过程中出现了错误或中断,导致系统文件损坏或丢失,从而无法正常启动。其次,可能是更新过程中出现了兼容性问题,导致某些硬件或驱动程序无法与新的系统版本兼...

取消回复欢迎 发表评论: