Afraid to restart nginx [duplicate]

A cowboy was here

A Cowboy was Here

nginx: [emerg] unknown directive "pagespeed"

This is why you have a copy of nginx in /usr/local, the pagespeed module has to be compiled into nginx. Good intentions (ahem*) explains multiple copies.

Nginx 1.0.15 is old (from 4/2012) so it's unlikely the system you have is using systemd so look for init scripts in /etc/init.d.

What I would do in this situation is create a VM of the same base OS and copy the following directory trees to it.

  • /etc/nginx
  • /usr/local/nginx-nobrotli/
  • Your production tree
  • relevant init scripts from /etc/init.d

Don't install nginx from your distro.

Now you have a test environment, you can figure stuff out.

Add /usr/local/nginx-nobrotli/sbin/nginx to your PATH

export /usr/local/nginx-nobrotli/sbin/nginx:$PATH

Now when you run nginx it will be running the locally compiled version, it should work as you expect. It may still throw curved balls depending on how it was compiled, for example you may need to use -c /etc/nginx/nginx.conf to ensure that it is picking up the correct config file. You could fix that with an alias.

How can I restart nginx ...

hopefully /etc/init.d/nginx restart (or similar) you'll have to figure that out based on what you find in your environment.

What's the best way to make the nginx -t ...

Remove all irrelevant versions (based upon testing) and adjust the PATH appropriately. See above regarding the config options.

what's the difference between ...

They are likely irrelevant given the output of your ps command. However in general they would be where the locally compiled nginx would expect to find it's config. We know that they are likely not in use from the ps command.

if the /usr/local/nginx* folders all contain a binary under their respective sbin/ folders, does that mean they are the same?

Not guaranteeably they may have differing compilation options.

why would someone have 3 versions like this?

Good intentions, testing, version control some other reason - you choose.

When you have figured it out document it. Go back to your prod system and remove the cruft. Negotiate a maintenance window and test what you learned and implemented.

*A Cowboy. I'm sure many people will recognise this, the better of us grow out of it.