nginx On x86 Architecture 2023-06-06
Most of my web server crap is running on nginx. For a long time Apache was the web server software of choice, but over the years it has lost its edge. I actually made the switch back in 2016. Anyways, I generally use Devuan Linux which has a few installation options for nginx. One is to simply use the version of nginx in the Debian/Devuan repositories. Another is to add the nginx.org repositories and install from there. The last option is to download the source for nginx and compile it yourself. Now in the past I would normally install whatever comes in the Deb/Dev repos... until recently. You see, I have this other side project that uses nginx for providing DNS-over-HTTPS, and as it turns out, those servers have been behaving a little crappy lately. It is strange and intermittent behaviour, so it is a little challenging to troubleshoot. Well, that and the fact that there are specifically no log files being recorded. Part of my issue seemed to be Unbound, and upgrading it helped with the problem. Another part of the issue seemed to be nginx, and upgrading it (by switching to the nginx.org repo) also helped.
Well, problem solved right? Sure, sort of. I figured it might also make sense to upgrade nginx on the web server that you are looking at now. So, I should just switch to the nginx.org repos and do the upgrade right? Wrong. The nginx.org repos do not support 32 bit OSs, and this server is 32 bit. Now before you go full retard on me... This server is a Proxmox based virtual machine with 1 CPU, 2GB of memory, and some small disk size with no big files. It runs all kinds of stuff. It runs some DNS stuff for the local LAN, prosody XMPP server, email services using postfix, dovecot, sqlgrey, spamassassin, as well as various web serving packages like gogs and radicale, and fail2ban. All this and there is well over half of the memory still available. Switching this to a 64 bit OS would be a waste and possibly less efficient. So... I compiled nginx, and it went kind of sweet.
I actually just left the version from the Deb/Dev repos installed and simply overwrote the /usr/sbin/nginx binary with the one I compiled and it works fine. So I imagine the next time Debian/Devuan has an update it will overwrite my compiled version; I guess I better keep and eye on that. Anyways, I used a separate virtual machine to do the compile like this:
# apt-get install build-essential binutils gcc libpcre3-dev libssl-dev zlib1g-dev
# mkdir /tmp/jackass && cd /tmp/jackass
# wget https://nginx.org/download/nginx-1.25.0.tar.gz
# tar xf nginx-1.25.0.tar.gz && cd nginx-1.25.0
# ./configure --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log \
--pid-path=/run/nginx.pid --lock-path=/var/lock/nginx.lock --with-http_ssl_module --with-http_v2_module --with-http_dav_module \
# make install
Of course you'd want to check the nginx download list first to make sure you are using the latest version. The newly compiled binary will be at /etc/nginx/sbin/nginx, and in my case I just put in in /usr/sbin on the web server box. If you didn't have the repo version installed you would probably also want to get the /etc/init.d/nginx file from the nginx-common archive:
# apt-get install binutils
# cd /tmp/jackass
# wget http://ftp.us.debian.org/debian/pool/main/n/nginx/nginx-common_1.18.0-6.1+deb11u3_all.deb
# ar x nginx-common_1.18.0-6.1+deb11u3_all.deb # tar xf data.tar.xz
You will then find ./etc/init.d/nginx which should be put in the /etc/init.d directory on the web server, and run:
# update-rc.d nginx defaults
Now your compiled version should run pretty much the same way the repo version would and you won't be running a three year old web server.