Last active
February 7, 2025 15:47
-
-
Save alexgurrola/4f7fc9a317a68a3895858e24c83ea437 to your computer and use it in GitHub Desktop.
ubuntu: compile and install nginx 1.25.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# NOTE: This requires openssl to be installed via https://gist.github.com/alexgurrola/db0736378d565bab3b2e35a66e7d9e50 to provide the necessary sources to install nginx with the latest openssl | |
# usage: wget https://gist.githubusercontent.com/alexgurrola/4f7fc9a317a68a3895858e24c83ea437/raw/install-nginx-1.25.2.sh && chmod +x install-nginx-1.25.2.sh && ./install-nginx-1.25.2.sh | |
# display current version | |
nginx -V | |
# install prerequisites | |
sudo apt update | |
sudo apt install build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev libgd-dev libxml2 libxml2-dev uuid-dev | |
# enter directory | |
cd /usr/local/src/ | |
# extract | |
sudo wget http://nginx.org/download/nginx-1.25.2.tar.gz | |
sudo tar -xf nginx-1.25.2.tar.gz | |
cd nginx-1.25.2 | |
# configure, compile, and install | |
sudo ./configure --with-openssl=/usr/local/src/openssl-3.1.3/ --prefix=/var/www/html --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 --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-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' | |
sudo make | |
sudo make install | |
# set permissions | |
sudo chmod 755 /usr/sbin/nginx | |
# display current version | |
nginx -V |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for your script for compiling nginx-1.25.2, but something was wrong, your configuration seems comes from official version from nginx.org, but there are 2
--prefix
option, please consider to remove one, and thank you for your work again!