linux - 从 bash 脚本安装 nginx 模块不起作用
问题描述
我使用 Nginx v16.1.1,我想安装 modsecurity。
如果我从命令行运行下面列出的命令,ModSecurity 模块将作为已安装模块出现在“nginx -V”中。
但是,如果我将脚本作为文件执行(例如 ./myscript.sh),它不会按预期安装模块。
#!/bin/sh
# Download and Install libModSecurity
cd /opt/
git clone https://github.com/SpiderLabs/ModSecurity
cd ModSecurity
git checkout v3/master
sh build.sh
git submodule init
git submodule update
./configure
# Build libModSecurity
make && make install
make check
# Download the ModSecurity Nginx connector
cd /opt/
git clone https://github.com/SpiderLabs/ModSecurity-nginx.git
#########
# Nginx #
#########
echo "Installing Nginx..."
# Download latest stable version
NGINX_VER='nginx-1.16.1'
cd /opt/
echo "Downloading $NGINX_VER..."
wget http://nginx.org/download/$NGINX_VER.tar.gz
tar xvzf $NGINX_VER.tar.gz
cd $NGINX_VER
./configure --prefix=/usr/share/nginx \
--with-debug \
--add-module=/opt/ModSecurity-nginx \
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' \
--with-ld-opt=' -Wl,-E'
# Install
make && make install
# Check installed modules
nginx -V
有任何想法吗?
解决方案
\
after将./configure
防止--with-debug
被读取为命令,这可能是导致此问题的原因(如果您具有必要的权限)
./configure \
--with-debug \
--add-module=/opt/ModSecurity-nginx \
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' \
--with-ld-opt=' -Wl,-E'
推荐阅读
- javascript - Cordova Media Plugin 多音频插件工作
- rabbitmq - 与多个 RabbitMQ 主机的强大 aio-pika 连接
- google-analytics - 即时禁用 GTM
- java - 在视图滚动时限制 OnBindViewHolder
- wordpress - 在页面上编辑 divi builder 不显示内容
- angular - Angular如何从http get请求中获取结果
- java - 在 Activiti Java Delegate 中启动进程和查询任务
- sql - 如何在 ssis 中将 .txt 字符限制更改为超过 4000 个字符
- javascript - 如何在 Angular 模板中显示日期和时间并保持更新?
- react-native - 创建 React Native 应用程序。- 插件/预设文件不允许导出对象,只有功能