@@ -3,13 +3,27 @@ all: opt
33NGINX_V := 1.26.2
44LIBRE_V := 4.0.0
55PASSENGER_V := 6.0.26
6- # Added by passenger itself: http_ssl_module http_v2_module http_realip_module http_gzip_static_module http_stub_status_module http_addition_module
76ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST ) ) ) )
7+ HOST_OS := $(shell if [ -f /etc/lsb-release ]; then echo debian; elif [ -f /etc/redhat-release ]; then echo fedora; else echo unknown; fi)
8+ DOWNLOAD_V ?= "" # option for install with prebuilt GitHub version
9+
810NGINX_PASSENGER_MODULES := --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_addition_module --add-module='$(ROOT_DIR ) passenger/src/nginx_module'
911NGINX_MODULES := --user=nginx --group=nginx --with-compat --with-debug --with-file-aio --with-http_v3_module --with-pcre --with-pcre-jit --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --with-openssl="../libressl"
1012NGINX_OPTIMIZATIONS := --with-cc-opt='-I../libressl/build/include -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -fstack-protector-strong -fasynchronous-unwind-tables -fstack-clash-protection' --with-ld-opt='-L../libressl/build/lib -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -Wl,-E'
1113NGINX_FEDORA_CONFIG := --sbin-path=/usr/local/sbin/nginx --modules-path=/usr/local/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
1214NGINX_DEBIAN_CONFIG := --sbin-path=/usr/local/sbin/nginx --modules-path=/usr/local/lib/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/body --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --http-scgi-temp-path=/var/lib/nginx/scgi --pid-path=/run/nginx.pid --lock-path=/var/lock/nginx.lock
15+ NGINX_TMP_FEDORA_DIRS := /var/lib/nginx/tmp/{client_body,fastcgi,proxy,scgi,uwsgi}
16+ NGINX_TMP_DEBIAN_DIRS := /var/lib/nginx/{body,fastcgi,proxy,scgi,uwsgi}
17+
18+ ifeq ($(HOST_OS ) ,fedora)
19+ NGINX_CONFIG := $(NGINX_FEDORA_CONFIG)
20+ NGINX_TMP_DIRS := $(NGINX_TMP_FEDORA_DIRS)
21+ else ifeq ($(OS),fedora)
22+ NGINX_CONFIG := $(NGINX_DEBIAN_CONFIG)
23+ NGINX_TMP_DIRS := $(NGINX_TMP_DEBIAN_DIRS)
24+ else
25+ $(error Unsupported OS detected)
26+ endif
1327
1428nginx-$(NGINX_V ) .tar.gz :
1529 curl -sSLO " https://www.nginx.org/download/nginx-$( NGINX_V) .tar.gz"
@@ -45,28 +59,20 @@ opt: nginx passenger libressl
4559
4660build : nginx passenger libressl
4761 rm -rf build
48- mkdir -p build/debian
62+ mkdir -p build
4963 ./passenger/bin/passenger-install-nginx-module --auto --languages=ruby,python,nodejs \
5064 --nginx-source-dir=./nginx --prefix=/usr/local/share/nginx --nginx-no-install \
51- " --extra-configure-flags=$( NGINX_DEBIAN_CONFIG) $( NGINX_MODULES) $( NGINX_OPTIMIZATIONS) "
52- cp -a nginx/objs/nginx build/debian/nginx
53- mkdir -p build/fedora
54- # For faster build we extract commands from passenger-install-nginx-module
55- cd nginx && sh ./configure --prefix='/usr/local/share/nginx' \
56- $(NGINX_PASSENGER_MODULES) $(NGINX_FEDORA_CONFIG) $(NGINX_MODULES) $(NGINX_OPTIMIZATIONS) && make
57- cp -a nginx/objs/nginx build/fedora/nginx
58- cp -a passenger/buildout build/passenger
59- find build -type f -name "*.o" -delete
60- tar -czvf nginx-builder.tar.gz build
65+ " --extra-configure-flags=$( NGINX_CONFIG) $( NGINX_MODULES) $( NGINX_OPTIMIZATIONS) "
66+ cp -a nginx/objs/nginx build/nginx
6167
6268install : nginx passenger libressl
6369# Run the Passenger installation with Nginx module
6470 ./passenger/bin/passenger-install-nginx-module --auto --languages=ruby,python,nodejs \
6571 --nginx-source-dir=./nginx --prefix=/usr/local --nginx-no-install \
66- "--extra-configure-flags=$(NGINX_FEDORA_CONFIG ) $(NGINX_MODULES) $(NGINX_OPTIMIZATIONS)"
72+ "--extra-configure-flags=$(NGINX_CONFIG ) $(NGINX_MODULES) $(NGINX_OPTIMIZATIONS)"
6773 cp -a nginx/objs/nginx /usr/local/sbin/nginx; chmod +x /usr/local/sbin/nginx
6874# Create necessary directories and set permissions
69- mkdir -p /usr/local/lib64/nginx/modules /var/log/nginx /var/lib/nginx/tmp/{client_body,fastcgi,proxy,scgi,uwsgi} /etc/nginx/conf.d /var/run/passenger-instreg
75+ mkdir -p /usr/local/lib64/nginx/modules /var/log/nginx $(NGINX_TMP_DIRS) /etc/nginx/conf.d /var/run/passenger-instreg
7076 getent group nginx > /dev/null || groupadd -r nginx && id -u nginx > /dev/null 2>&1 || useradd -r -g nginx -s /sbin/nologin -d /nonexistent -c "nginx user" nginx
7177 chmod 0700 -R /var/log/nginx /var/lib/nginx/
7278 chown -R nginx:root /var/lib/nginx
0 commit comments