Alpine Linux에서 nginx 설치하기

·2025년 3월 1일
apk update
apk upgrade

apk add build-base linux-headers pcre2-dev openssl-dev
addgroup -S nginx
adduser -S -G nginx -s /sbin/nologin nginx
cd /opt

wget https://nginx.org/download/nginx-1.27.4.tar.gz
wget https://github.com/openresty/headers-more-nginx-module/archive/refs/tags/v0.38.tar.gz

tar -zxf nginx-1.27.4.tar.gz
tar -zxf v0.38.tar.gz

cd nginx-1.27.4

./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/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 --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --with-perl_modules_path=/usr/lib/perl5/vendor_perl --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_v3_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-Os -fstack-clash-protection -Wformat -Werror=format-security -fno-plt -g' --with-ld-opt='-Wl,--as-needed,-O1,--sort-common -Wl,-z,pack-relative-relocs' --add-module=/opt/headers-more-nginx-module-0.38

make && make install
vi /etc/init.d/nginx
#!/sbin/openrc-run

name=nginx

command="/usr/sbin/nginx"
command_args="-c /etc/nginx/nginx.conf"
pidfile="/var/run/nginx.pid"
rc-update add nginx default
rc-service nginx start
profile

0개의 댓글