简体   繁体   中英

installing nginx module from bash script doesn't work

I use Nginx v16.1.1 and I want to install modsecurity.

If I run the commands listed below from command line, the ModSecurity module will appear in "nginx -V" as an installed module.

However, if I execute the script as file (eg ./myscript.sh) it doesn't install the module as expected.

#!/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

Any ideas?

The \\ after ./configure will prevent --with-debug being read as a command which is probably what is probably what's causing this (if you have the necessary permissions)

./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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM