Page 1 of 2

[SOLVED]Sites not avaible after reboot (nginx failed to start)

Posted: Sat Nov 18, 2017 9:57 pm
by Holiday
Hello,

Each time i reboot the server my site are not working (but vesta pannel is ok), i have to execute the cli command "v-rebuild-user admin" in order to make things work again.

The only change i've mage recently is to create a new snginx template (based on the original but edited for a specific website).

Do you have any idea of what's wrong and how i can solve this?

Thanks for your time.

EDIT: this solved my problem : https://stackoverflow.com/questions/204 ... 6#20532666

Re: Sites not avaible after reboot

Posted: Mon Nov 20, 2017 10:13 pm
by skamasle
Can you check if apache and nginx start after reboot ?

Re: Sites not avaible after reboot

Posted: Mon Dec 18, 2017 12:29 pm
by Holiday
Sorry for the response delay (i have notifications on now).

From memory nginx and apache where started (it was the first thing i looked for). As i said, the command "v-rebuild-user" solves it till the next reboot. I think it's related to the custom nginx and apache templates i've made (to force the directory of one of the subdomain) because it works again after i run "v-rebuild-user". I will try tomorrow with the command "v-rebuild-web-domains" after restart but if you have some other tests for me to try, feel free to ask. (I have to run the tests early in the morning because i have to reboot the server to run the tests and it shuts the site down ).

apache template :

Code: Select all


<VirtualHost %ip%:%web_port%>

    ServerName %domain_idn%
    %alias_string%
    ServerAdmin %email%
    DocumentRoot /home/admin/web/mysite.fr/public_html
    ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/
    Alias /vstats/ %home%/%user%/web/%domain%/stats/
    Alias /error/ %home%/%user%/web/%domain%/document_errors/
    #SuexecUserGroup %user% %group%
    CustomLog /var/log/%web_system%/domains/%domain%.bytes bytes
    CustomLog /var/log/%web_system%/domains/%domain%.log combined
    ErrorLog /var/log/%web_system%/domains/%domain%.error.log
    <Directory /home/admin/web/mysite.fr/public_html>
        AllowOverride All
        Options +Includes -Indexes +ExecCGI
    </Directory>
    <Directory %home%/%user%/web/%domain%/stats>
        AllowOverride All
    </Directory>

    <IfModule mod_ruid2.c>
        RMode config
        RUidGid %user% %group%
        RGroups www-data
    </IfModule>
    <IfModule itk.c>
        AssignUserID %user% %group%
    </IfModule>

    Include %home%/%user%/conf/web/%web_system%.%domain%.conf*

</VirtualHost>
nginx template is the same as the original (see below) because all i want is a common directory for my subdomain (but not logs). And it works perfectly on production since a couple of month (but not after restart apparently).

Code: Select all

server {
    listen      %ip%:%proxy_port%;
    server_name %domain_idn% %alias_idn%;
    error_log  /var/log/%web_system%/domains/%domain%.error.log error;

    location / {
        proxy_pass      http://%ip%:%web_port%;
        location ~* ^.+\.(%proxy_extentions%)$ {
            root           %docroot%;
            access_log     /var/log/%web_system%/domains/%domain%.log combined;
            access_log     /var/log/%web_system%/domains/%domain%.bytes bytes;
            expires        max;
            try_files      $uri @fallback;
        }
    }

    location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location @fallback {
        proxy_pass      http://%ip%:%web_port%;
    }

    location ~ /\.ht    {return 404;}
    location ~ /\.svn/  {return 404;}
    location ~ /\.git/  {return 404;}
    location ~ /\.hg/   {return 404;}
    location ~ /\.bzr/  {return 404;}

    include %home%/%user%/conf/web/nginx.%domain%.conf*;
}

Thanks again for your time

Re: Sites not avaible after reboot

Posted: Thu Dec 28, 2017 12:09 pm
by Holiday
Ok, you were right, nginx is not up at startup.

The only thing i have in nginx error log is that line

Code: Select all

2017/12/28 12:54:49 [emerg] 2114#2114: bind() to 163.XXX.XXX.59:80 failed (99: Cannot assign requested address)
(I have 2 ip for the serveur and 163.XXX.XXX.59 is my main ip)

After starting nginx, everything is back to normal. So now i have to solve why nginx is not starting. If you have any idea your help will be welcome.

Re: Sites not avaible after reboot

Posted: Thu Dec 28, 2017 12:59 pm
by mehargags

Code: Select all

systemctl enable nginx

Re: Sites not avaible after reboot

Posted: Thu Dec 28, 2017 1:30 pm
by Holiday
It returns me "-bash: systemctl: command not found"

EDIT: I think it's related to the error mentionned above and not about the fact that nginx autostarts or not ... But idk you seems to know what you're doing :\

Re: Sites not avaible after reboot

Posted: Thu Dec 28, 2017 8:20 pm
by mehargags
That means you are not on a systemd version of Linux, that is why it is very very important to state what OS and Version you are on when opening a thread. No one can help you without this minimum information.

If you could just give your fingers a bit trouble to search Google how to auto start linux service

Also this detailed article gives good insight
How To Configure a Linux Service to Start Automatically After a Crash or Reboot

Re: Sites not avaible after reboot

Posted: Fri Dec 29, 2017 8:41 am
by Holiday
OK i'm obviously bothering you, and just so you know i looked for a topic called "Before posting" and didn't found one, so i made the best i could when posting (and didn't complained).

So first of all, my services such as apache, mysql, mailserver etc... they autoruns perfectly, moreover i use vesta on other servers and never had this problem. Plus, nginx is configured for autostarts and i think that vestacp is very powerfull enough to autostarts all the daemons. So that's why i didn't googled the "systemd solution" (i just want to solve the problem to the root, even if systemd is able to retry starting nginx until it succeed).

To finish, i know how to use google but looking for systemd wasn't relevant, since nginx autostarts. Nginx triggers an error at startup (see 5 posts above) so i think this is the cause of the problem.

Here is my runlevel directories dump if you want the proof that nginx is already set to autostart.

Code: Select all

/etc/rc0.d:
K01apache2           K01nginx          K02mysql         K07networking
K01atd               K01openntpd       K02quota         K08umountfs
K01clamav-freshclam  K01quotarpc       K02spamassassin  K09mdadm-raid
K01dovecot           K01urandom        K03sendsigs      K09umountroot
K01exim4             K01vesta          K04rsyslog       K10mdadm-waitidle
K01fail2ban          K02bind9          K05umountnfs.sh  K11halt
K01mdadm             K02clamav-daemon  K07hwclock.sh    README

/etc/rc1.d:
K01apache2           K01mdadm     K02bind9          S01killprocs
K01atd               K01nginx     K02clamav-daemon  S01motd
K01clamav-freshclam  K01openntpd  K02mysql          S19bootlogs
K01dovecot           K01quotarpc  K02spamassassin   S20single
K01exim4             K01vesta     K04rsyslog
K01fail2ban          K01vsftpd    README

/etc/rc2.d:
README      S17bind9          S17quotarpc      S19clamav-freshclam
S01motd     S17clamav-daemon  S17spamassassin  S19cron
S16nginx    S17dbus           S17ssh           S19dovecot
S16rsyslog  S17fail2ban       S17vesta         S19exim4
S16sudo     S17mdadm          S17vsftpd        S19rsync
S17acpid    S17mysql          S18apache2       S20rc.local
S17atd      S17openntpd       S19bootlogs      S20rmnologin

/etc/rc3.d:
README      S17bind9          S17quotarpc      S19clamav-freshclam
S01motd     S17clamav-daemon  S17spamassassin  S19cron
S16nginx    S17dbus           S17ssh           S19dovecot
S16rsyslog  S17fail2ban       S17vesta         S19exim4
S16sudo     S17mdadm          S17vsftpd        S19rsync
S17acpid    S17mysql          S18apache2       S20rc.local
S17atd      S17openntpd       S19bootlogs      S20rmnologin

/etc/rc4.d:
README      S17bind9          S17quotarpc      S19clamav-freshclam
S01motd     S17clamav-daemon  S17spamassassin  S19cron
S16nginx    S17dbus           S17ssh           S19dovecot
S16rsyslog  S17fail2ban       S17vesta         S19exim4
S16sudo     S17mdadm          S17vsftpd        S19rsync
S17acpid    S17mysql          S18apache2       S20rc.local
S17atd      S17openntpd       S19bootlogs      S20rmnologin

/etc/rc5.d:
README      S17bind9          S17quotarpc      S19clamav-freshclam
S01motd     S17clamav-daemon  S17spamassassin  S19cron
S16nginx    S17dbus           S17ssh           S19dovecot
S16rsyslog  S17fail2ban       S17vesta         S19exim4
S16sudo     S17mdadm          S17vsftpd        S19rsync
S17acpid    S17mysql          S18apache2       S20rc.local
S17atd      S17openntpd       S19bootlogs      S20rmnologin

/etc/rc6.d:
K01apache2           K01nginx          K02mysql         K07networking
K01atd               K01openntpd       K02quota         K08umountfs
K01clamav-freshclam  K01quotarpc       K02spamassassin  K09mdadm-raid
K01dovecot           K01urandom        K03sendsigs      K09umountroot
K01exim4             K01vesta          K04rsyslog       K10mdadm-waitidle
K01fail2ban          K02bind9          K05umountnfs.sh  K11reboot
K01mdadm             K02clamav-daemon  K07hwclock.sh    README

/etc/rcS.d:
README               S07checkroot-bootclean.sh  S12networking
S01hostname.sh       S07kmod                    S15mountnfs.sh
S01mountkernfs.sh    S07mtab.sh                 S16mountnfs-bootclean.sh
S02udev              S08checkfs.sh              S17kbd
S03keyboard-setup    S09mountall.sh             S18console-setup
S04mdadm-raid        S10mountall-bootclean.sh   S19bootmisc.sh
S04mountdevsubfs.sh  S11procps                  S19quota
S05hwclock.sh        S11udev-mtab
S06checkroot.sh      S11urandom
I'm ready to try your solution, but you should explain to me briefly why this is the solution :\

So thanks for your help, i know it's not an easy job to moderate a forum, but i'm trying to do my best to help you helping me.

Re: Sites not avaible after reboot

Posted: Fri Dec 29, 2017 8:56 am
by mehargags
You yourself stated, NGINX is not enabled on startup while this is usually not true. All important webservices are checked to be autostarting. If they don't it usually means there is an error in their config. To check what is the error, you need to do

Code: Select all

nginx -t
and then clean the error.

I don't mean to be rude... but the reality is that you are being a complete noob here. You are trying too hard, but not in the right direction.
What has runlevel to do with anything here when Nginx is not starting because of config error?

After writing so long, you still did not state the FIRST, MOST IMPORTANT INFORMATION :
WHAT IS YOUR OPERATING SYSTEM, AND ITS VERSION

We are here to help, but when you jump the gun, do not listen to members trying to help and keep on pasting irrelevant findings while failing to provide the right information, it obviously moves the interest away.

Re: Sites not avaible after reboot

Posted: Fri Dec 29, 2017 9:21 am
by Holiday
Ok this is what nginx -t returns

Code: Select all

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
And my debian version is 7.11