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

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

off999 2025-02-21 14:49 66 浏览 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之家 官方镜像)

1、去微软官方网站下载。2、去系统之家下载,我自己的win10就是从哪里下载安装的,你可以试试哈。ghost镜像的使用一、备份主分区--C盘:假设你的操作系统安装在主分区--C盘,当系统重装不久,或...

win7文件类型怎么更改(win7文件类型怎么更改不了)

重建文件关联,右击word文件,选择打开方式,选择word后同时选中下方的“始终用此程序打开”,如果不行的话可能就是文件关联的图标失效了,也就是文件关联是正常的,但是找不到图标,win7的话可以用wi...

下载设置功能到手机桌面(设置下载安装到手机桌面)

华为手机怎么安装下载内容?1.打开华为应用市场后点击上方的“管理”。2.再点击进入“安装管理”。3.在下载好但没有桌面图标的APP那里点击“∨”处,再点“管理”就能查看到此应用的应用信息。4.选择其...

win7旗舰版恢复出厂设置视频教程

在Windows系统中恢复出厂设置的方法如下:通过Windows系统恢复:关闭电脑,然后按住电源按钮,直到电脑启动,进入Windows启动管理器。选择“疑难解答”或“高级选项”。选择“重置此电脑”,然...

win7分辨率不能调整怎么办(win7屏幕分辨率调不了怎么办 电脑分辨率调整)
win7分辨率不能调整怎么办(win7屏幕分辨率调不了怎么办 电脑分辨率调整)

1、首先检查显示器要设置的分辨率是否支持,方法是:在电脑空白处用鼠标右击选择“屏幕分辨率——高级设置”。在弹出来的属性窗口中,“适配器”选项卡下点击“列出所有模式”按钮,就可以看到里面所支持的分辨率,如果没有所设置的值,则说明不支持,所以就...

2026-01-07 20:03 off999

qq空间登录电脑版入口(qq空间登录电脑版入口官网)
qq空间登录电脑版入口(qq空间登录电脑版入口官网)

z.qq.com可以通过以下方式登录手机QQ空间:1、使用手机登录手机腾讯网3g.qq.com,点击“空间”,根据提示QQ号码和QQ密码就可以登录;2、通过手机直接输入手机QQ空间网址z.qq.com,根据提示操作即可登录;3、下载手机Q...

2026-01-07 19:51 off999

win10下载官网下载不了(win10下载官网为什么打不开)

可能有几个原因导致您无法在官网下载Windows10。首先,您需要确保您正在访问Microsoft官网,因为只有在官网上才能下载Windows10。如果您已经在官网上但仍然无法下载,可能是因为服务...

lenovo键盘锁住了怎么解锁(lenovo电脑键盘锁了怎么解锁)
lenovo键盘锁住了怎么解锁(lenovo电脑键盘锁了怎么解锁)

情况一:有时候只是键盘的键位被锁住了,我们可以尝试通过FN+F8解锁,这种方法适用于笔记本。如果是键盘上的数字键盘锁住了,可以按一下NumLock键位解锁,看到上面有个灯亮了就说明解锁了。情况二:1、首先鼠标右键点击此电脑图标,然后点击管理...

2026-01-07 18:51 off999

vivo手机怎么切换经典桌面(vivo手机从哪里切换经典桌面)
vivo手机怎么切换经典桌面(vivo手机从哪里切换经典桌面)

  1、从手机桌面中找到变形器的图标。   2、选择带有安卓系统的图标就可以从平行空间退出,并切换到经典桌面。   3、想要再次进入平行空间的话只...

2026-01-07 18:03 off999

磁盘写保护的解除方法(磁盘写保护如何处理)
  • 磁盘写保护的解除方法(磁盘写保护如何处理)
  • 磁盘写保护的解除方法(磁盘写保护如何处理)
  • 磁盘写保护的解除方法(磁盘写保护如何处理)
  • 磁盘写保护的解除方法(磁盘写保护如何处理)
硬盘安装步骤(硬盘的安装教程)

   随着电脑技术不断改进和发展。硬盘的技术也在不断更新,从过去的几百兆、几个G、几十G、几百G到如今的几个T硬盘容量赿来赿大,读写速度赿来趆快。但硬盘安装的步骤几乎...

pe启动工具(pe启动工具排行榜)

u盘pe是可以重复使用的,没有问题的,可以给无数的电脑安装系统。用u盘的做的pe只要不是中病毒,或者你格式化u盘,里面的pe系统一直都是可以用的哈。只是说现在的pe系统最新的更新的技术不一样,...

笔记本电脑按键失灵怎么解决

笔记本电脑按键失灵可能是由于键盘内部灰尘或者物质堵塞,也可能是由于键盘接触不良或者硬件故障导致。修复方法可以尝试清洗键盘或更换键盘,如果还是不行则需要检查硬件或者寻求专业维修人员的帮助。在日常使用中,...

苹果手机imei查询官网(苹果手机imei查询官网免费)

IMEI查询官网:首页:http://www.imeidb.comIMEIdb的客户包括了国内知名手机厂商、IMEIdb始创于2011年IMEIdb是国内唯一的提供面向普通用户和商业用户的IMEI一体...

qq如何修改登录密码(qq怎么修改登录密码)
  • qq如何修改登录密码(qq怎么修改登录密码)
  • qq如何修改登录密码(qq怎么修改登录密码)
  • qq如何修改登录密码(qq怎么修改登录密码)
  • qq如何修改登录密码(qq怎么修改登录密码)

取消回复欢迎 发表评论: