Question

Restore/repair nginx after configtest fail

Posted February 27, 2015 10.5k views

Hi there,
In my LEMP stack my nginx got broken, i wonder if i can fix it or else stille backup some stuff before reverting to a previous snapshot. Lemp was set up with a tut here on DigitalOcean.

So what happened?
After some work in wp multi install (setting up sites/plugins and adding/editing content) i’ve decided to make a snapshot, i used a terminal with ssh and i entered poweroff.

Which was not smart… Better had i used shutdown

But anyways the snapshot was made. Then, not yet aware of any problems i ran an apt-get update and apt-get upgrade.

With the droplet activated my sites dont work anymore a service nginx configtest returned fail just as service nginx restart does. Reverting to the snapshot ive just made didnt work.

My guess ( i am a novice) is that ubuntu works fine, that just nginx got corrupted.

1 can i exactly diagnose what is wrong, and what is affected? How do i proceed?
2 can i fix nginx if yes how should i do this?
3 if not and i have to revert to an much earlier snapshot, is there a script available to still backup my multisite?
4 could i run xcloner from another location and pull a backup from the droplet over sftp?

would:
apt-get -f install – try to fix broken packages
dpkg –configure -a – try to fix broken

be a good start?
packages

Any help is greatly appreciated!

Working with terminal commands: i am new to it, but exploring
I keep an sftp window open to have some visual feedback

3 comments
  • if i just enter nginx i get:
    nginx
    nginx: [emerg] “rewrite” directive is not allowed here in /etc/nginx/sites-enabled/wp-ms:48

  • Looks like your directives on /etc/nginx/sites-enabled/wp-ms:48 are wrong, correct the line and try restart.

    If you update nginx with a package manager your old config file is copied to a backup file in same directory, ie: nginx.conf -> nginx.bak so try to check for it, not sure in ubuntu but look on /etc/nginx/

  • It is solved! i made a typo in the server block, all is up and running again!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

This question was answered by @EpicCDN:

Looks like your directives on /etc/nginx/sites-enabled/wp-ms:48 are wrong, correct the line and try restart.

If you update nginx with a package manager your old config file is copied to a backup file in same directory, ie: nginx.conf -> nginx.bak so try to check for it, not sure in ubuntu but look on /etc/nginx/

View the original comment

Submit an Answer