centos升级nginx,增加fastdfs插件

发布时间 2023-12-19 09:42:13作者: 进击小螺号

首先到安装目录下

cd /usr/local/nginx

1、首先下载需要的版本

cd /usr/local
wget -c http://nginx.org/download/nginx-1.22.1.tar.gz

2、解压

tar zxvf nginx-1.22.1.tar.gz

3、备用一下旧版本以防意外(我的旧版本是1.22.0版本)

cd /usr/local/nginx/sbin
./nginx -s stop mv nginx nginx
-1.22.0

4、到解压文件夹下

cd /usr/local/nginx-1.22.1/
#增加插件时使用(先查找插件fastdfs-nginx-module的位置,然后再修改以下位置 /usr/local/nginx/fastdfs-nginx-module-master/src ):
./configure  --add-module=/usr/local/nginx/fastdfs-nginx-module-master/src  --prefix=/usr/local/nginx   --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-pcre&&make
不增加插件时使用:
./configure  --prefix=/usr/local/nginx   --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-pcre&&make

备注:增加插件  fastdfs-nginx-module


没有这个插件可以去官方下载:https://github.com/happyfish100/fastdfs-nginx-module/tags ,这个东西要下载指定版本,否则会编译出错
查找原来的插件位置:
find / -name fastdfs-nginx-modul*
返回: /usr/local/nginx/fastdfs-nginx-module-master
单独增加安装插件命令:
cd /usr/local/nginx-1.22.1/
./configure --add-module=/usr/local/nginx/fastdfs-nginx-module-master/src
make && make install

5、安装

# 到原来的安装目录下
cd /usr/local/nginx/sbin
#拷贝
cp -rf /usr/local/nginx-1.22.1/objs/*  ./
# 查看已安装版本
/usr/local/nginx/sbin/nginx -V
# 启动nginx
sudo /usr/local/nginx/sbin/nginx

报错: .nginx: [emerg] unknown directive “ngx_fastdfs_module” in /usr/local/nginx/conf/nginx.conf:40