安装nginx 1.16.1版本

vi /etc/yum.repos.d/nginx.repo

[nginx-stable]

name=nginx stable repo

baseurl=http://nginx.org/packages/centos/$releasever/$basearch/

gpgcheck=1

enabled=1

gpgkey=https://nginx.org/keys/nginx_signing.key

[nginx-mainline]

name=nginx mainline repo

baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/

gpgcheck=1

enabled=0

gpgkey=https://nginx.org/keys/nginx_signing.key

通过yum search nginx看看是否已经添加源成功。如果成功则执行下列命令安装nginx。

yum install -y nginx-1.16.1

 

=============

如何动态地为Nginx添加扩展模块

请您参考以下步骤进行操作,此处以安装第三方ngx_http_google_filter_module模块为例。

说明:Nginx的模块是需要重新编译Nginx,而不是像Apache一样配置文件引用.so

执行以下命令下载第三方扩展模块。
cd /data/software/ 
git clone https://github.com/cuber/ngx_http_google_filter_module
将命令行切换到Nginx执行程序所在的目录。
cd /usr/local/nginx-1.9.3/sbin
输入以下命令查看Nginx已安装的模块参数。
./nginx -V 
系统返回信息。
nginx version: nginx/1.9.3 
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) 
built with OpenSSL 1.0.2 22 Jan 2015 
TLS SNI support enabled 
configure arguments: --prefix=/usr/local/nginx-1.9.3 --with-openssl=/usr/local/src/openssl-1.0.2 --with-pcre=/usr/local/src/pcre-8.37 --with-zlib=/usr/local/src/zlib-1.2.8 --with-http_ssl_module 
说明:可以看出编译安装使用--prefix=/usr/local/nginx-1.9.3、--with-openssl=/usr/local/src/openssl-1.0.2、--with-pcre=/usr/local/src/pcre-8.37、 --with-zlib=/usr/local/src/zlib-1.2.8、--with-http_ssl_module这些参数。
执行以下命令备份原来的Nginx执行程序 。
cp /usr/local/nginx-1.9.3/sbin/nginx /usr/local/nginx-1.9.3/sbin/nginx.bak 
执行以下命令切换到Nginx安装包所在的目录。
cd /opt/nginx-1.9.3
说明:此处的目录路径请根据实例中具体安装目录决定。
加入需要安装的模块,执行以下代码。
./configure --prefix=/usr/local/nginx-1.9.3 --with-openssl=/usr/local/src/openssl-1.0.2 --with-pcre=/usr/local/src/pcre-8.37 --with-zlib=/usr/local/src/zlib-1.2.8 --with-http_ssl_module -–add-module=/data/software/ngx_http_google_filter_module 
说明:添加-–add-module=/data/software/ngx_http_google_filter_module模块。
执行make命令进行编译即可。
注意:千万不要make install命令,不然会覆盖已安装内容。

 

posted on 2023-07-26 18:24  我和你并没有不同  阅读(253)  评论(0编辑  收藏  举报