5

I've installed NGINX with sudo apt-get install nginx and now I'd like to recompile it with the configure option --with-http_stub_status_module.

How can I do this, and is there a way I can not loose all of my /etc/nginx configuration?

Thanks! Tom.

tarnfeld
  • 481
  • 2
  • 6
  • 13
  • Duplicate of https://serverfault.com/questions/227480/installing-optional-nginx-modules-with-apt-get – Denis Pshenov Dec 05 '19 at 19:23
  • Does this answer your question? [Installing optional Nginx modules with apt-get](https://serverfault.com/questions/227480/installing-optional-nginx-modules-with-apt-get) – Denis Pshenov Dec 05 '19 at 19:24

2 Answers2

6

Download the source from nginx.org and unpack it. Use/path/to/your/nginx/binary -V to get your current configure line.

Modify it as you see fit, and run the configure file from the nginx source with your new configure line. Then run make, make install and make upgrade and you're all updated.

Martin Fjordvald
  • 7,589
  • 1
  • 28
  • 35
  • This sounds like the best solution! I'll try it out and let you know how it goes :-) Thanks! – tarnfeld Jun 12 '11 at 15:12
  • where is that configure file located? i cant find it to edit it – Kristian Mar 01 '12 at 15:19
  • I am trying to run @Martin F's update and it will not let me. Did you run into any issues with this installation? I get through all the make steps, however, even after a reboot when I run nginx -v I still see: nginx: nginx version: nginx/1.0.10 nginx: TLS SNI support enabled nginx: configure arguments: --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp- – Chris Hough Dec 03 '11 at 22:38
4

I agree with "Martin F" -- he described the simplest and proven way to upgrade Nginx from the official sources.

However, some people would like to go "Debian way" of installing source packages. In this case, the scenario is as follows:

  1. You must have dpkg-dev, dpatch, devscripts installed
  2. Go to the directory where you build packages, e.g. /usr/src. Download Nginx package sources: apt-get source nginx=1.0.4
  3. Directory nginx-1.0.4 contains Nginx sources along with Debian package configuration, installation script, etc. If you just want to add another option to Nginx configuration command line, edit debian/rules file. Note that Nginx package comes in three flavors: extra, full and I don't remember the third. Choose whatever you like and modify its configuration.
  4. Update the ChangeLog: dch --local your-user-id 'Added perl module; Removed ipv6, mail, xslt modules'
  5. Build the package: debuild -us -uc -b

After this, you should have Debian packages (e.g. nginx-full_1.0.4-1your-user-id1_amd64.deb) in /usr/src. Just install the package of your choice with dpkg -i <file>

Alexander Azarov
  • 3,510
  • 20
  • 19
  • A nice article explaining this in more detail can be found here: https://serversforhackers.com/c/compiling-third-party-modules-into-nginx – Denis Pshenov Dec 05 '19 at 19:22