Learn about Centmin Mod LEMP Stack today
Become a Member

Make Nginx robust, always to load conf vhost even if has error

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by Sysnet, May 2, 2022.

  1. Sysnet

    Sysnet New Member

    7
    0
    1
    Nov 17, 2020
    Ratings:
    +0
    Local Time:
    4:07 AM
    There are multiple site config in my nginx, and when I restart the machine, if one of the sites' (vhost) has any error, nginx won't start at all, and those healthy site won't start as a result.

    Maybe I can code a program who detect this case and ignore this vhost and temporary set a template vhost (under maintenance), what do you think about this idea?


    do you know some webserver or script/panel who has this feature ?
     
  2. eva2000

    eva2000 Administrator Staff Member

    48,440
    11,102
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,281
    Local Time:
    7:07 PM
    Nginx 1.21.x
    MariaDB 10.x
    You can run nginx config debug check command to see if vhost or settings are incorrect
    Code (Text):
    nginx -t
     
  3. deltahf

    deltahf Premium Member Premium Member

    518
    230
    43
    Jun 8, 2014
    Ratings:
    +412
    Local Time:
    5:07 AM
    You can also run "configtest" before restarting Nginx. It will test the config and report any errors before attempting restart:

    Code (Text):
    $ service nginx configtest
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    
     
  4. eva2000

    eva2000 Administrator Staff Member

    48,440
    11,102
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,281
    Local Time:
    7:07 PM
    Nginx 1.21.x
    MariaDB 10.x
    Yup same as nginx -t :D