Recompile Nginx on production environement

In case you don’t have an Nginx cluster or you are not powered in a cloud base infrastructure then recompiling the webserver may be a tricky job. If you are in one of the described situation you can setup all instances one by one having a stable platform.

Even so of course you can recompile the webserver without downtime.

  1. Create backups for all nginx files.
  2. Download all sources and dependencies for nginx
  3. Configure the compilation with custom parameters. You can even specify an other binary location for the new compiled software. In this way all the installed software will sill exist in the original files. In my case I decided to overwrite the existing binary of nginx.
    “/usr/local/nginx/sbin/nginx -V”
  4. Compile and install
  5. Sometimes this step is a little bit risky because some files may be opened and could not be overwritten. In my case everything worked fine.  Even if the service was running in this time, the binary was already replaced.
  6. If you decided to go on a safer way and installed the binary in other place now all you have to change is defining your daemon to use this binary instead of old one, test the nginx configuration and restart the service.

A much more complex aprouch may be found here