Learn about Centmin Mod LEMP Stack today
Become a Member

Nginx ngxrestart

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by Itworx4me, Jun 16, 2022.

  1. Itworx4me

    Itworx4me Active Member

    254
    26
    28
    Mar 14, 2017
    Ratings:
    +44
    Local Time:
    1:32 AM
    Nginx 1.21.X
    MariaDB 10.3.X
  2. Jon Snow

    Jon Snow Active Member

    662
    129
    43
    Jun 30, 2017
    Ratings:
    +190
    Local Time:
    5:32 AM
    Nginx 1.13.9
    MariaDB 10.1.31
    Use:
    Code (Text):
    nprestart
     
  3. Itworx4me

    Itworx4me Active Member

    254
    26
    28
    Mar 14, 2017
    Ratings:
    +44
    Local Time:
    1:32 AM
    Nginx 1.21.X
    MariaDB 10.3.X
    I still get a no such file or directory using your code but seems to restart
    Code (Text):
    [root@XXXX ~]# nprestart
    /usr/bin/nprestart: line 1: /etc/init.d/nginx: No such file or directory
    Restarting php-fpm (via systemctl) [  OK  ]
     
  4. eva2000

    eva2000 Administrator Staff Member

    49,037
    11,235
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,487
    Local Time:
    6:32 PM
    Nginx 1.21.x
    MariaDB 10.x
    If you're using 130.00beta01 then might have ran into the same bug @Rhodium ran into with fix outlined in update at https://community.centminmod.com/threads/cron-error.22933/#post-93463
     
  5. JoeDer

    JoeDer Member

    82
    19
    8
    Feb 22, 2015
    Ratings:
    +48
    Local Time:
    11:32 AM
    Nginx 1.21.x
    MariaDB 10.3.x
    I had the same issue and fixed it by uploading the missing nginx file in /etc/rc.d/init.d
    Code (Text):
    #!/bin/sh
    ulimit -n 524288
    # => /etc/init.d/nginx
    # => sudo chmod +x /etc/init.d/nginx
    # => make it start when the server run: /sbin/chkconfig nginx on
    # => to check it: /sbin/chkconfig --list nginx
    # nginx - this script starts and stops the nginx daemin
    # Taken from http://www.hikaro.com
    # chkconfig:   - 85 15 
    # description:  Nginx is an HTTP(S) server, HTTP(S) reverse \
    #               proxy and IMAP/POP3 proxy server
    # processname: nginx
    # config:      /usr/local/nginx/conf/nginx.conf
    # pidfile:     /usr/local/nginx/logs/nginx.pid
    
    # Source function library.
    . /etc/rc.d/init.d/functions
    
    # Source networking configuration.
    . /etc/sysconfig/network
    
    # Check that networking is up.
    [ "$NETWORKING" = "no" ] && exit 0
    
    nginx="/usr/local/sbin/nginx"
    prog=$(basename $nginx)
    
    NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
    
    lockfile=/var/lock/subsys/nginx
    
    start() {
        [ -x $nginx ] || exit 5
        [ -f $NGINX_CONF_FILE ] || exit 6
        echo -n $"Starting $prog: "
        daemon $nginx -c $NGINX_CONF_FILE
        retval=$?
        echo
        [ $retval -eq 0 ] && touch $lockfile
        return $retval
    }
    
    stop() {
        echo -n $"Stopping $prog: "
        killproc $prog -QUIT
        retval=$?
        echo
        [ $retval -eq 0 ] && rm -f $lockfile
        return $retval
    }
    
    restart() {
        configtest || return $?
        stop
        start
    }
    
    reload() {
        configtest || return $?
        echo -n $"Reloading $prog: "
        killproc $nginx -HUP
        RETVAL=$?
        echo
    }
    
    force_reload() {
        restart
    }
    
    configtest() {
      $nginx -t -c $NGINX_CONF_FILE
    }
    
    rh_status() {
        status $prog
    }
    
    rh_status_q() {
        rh_status >/dev/null 2>&1
    }
    
    case "$1" in
        start)
        rh_status_q && exit 0
        $1
        ;;
        stop)
        rh_status_q || exit 0
        $1
        ;;
        restart|configtest)
        $1
        ;;
        reload)
        rh_status_q || exit 7
        $1
        ;;
        force-reload)
        force_reload
        ;;
        status)
        rh_status
        ;;
        condrestart|try-restart)
        rh_status_q || exit 0
            ;;
        *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
        exit 2
    esac
    
     
  6. eva2000

    eva2000 Administrator Staff Member

    49,037
    11,235
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,487
    Local Time:
    6:32 PM
    Nginx 1.21.x
    MariaDB 10.x
  7. Itworx4me

    Itworx4me Active Member

    254
    26
    28
    Mar 14, 2017
    Ratings:
    +44
    Local Time:
    1:32 AM
    Nginx 1.21.X
    MariaDB 10.3.X
    In the fixed version it doesn't produce this line anymore:
    Code (Text):
    Restarting php-fpm (via systemctl) [  OK  ]

    I guess you just have to assume it restarted???
     
  8. eva2000

    eva2000 Administrator Staff Member

    49,037
    11,235
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,487
    Local Time:
    6:32 PM
    Nginx 1.21.x
    MariaDB 10.x
    there's 2 command shortcuts

    restart nginx only
    Code (Text):
    ngxrestart
    

    Code (Text):
    ngxrestart
    Redirecting to /bin/systemctl restart nginx.service
    

    restart nginx + php-fpm
    Code (Text):
    nprestart
    

    Code (Text):
    nprestart
    Redirecting to /bin/systemctl restart nginx.service
    Restarting php-fpm (via systemctl) [  OK  ]