Page 1 of 1

NGINX and HTTPD not starting at reboot

Posted: Tue Dec 20, 2016 5:11 pm
by pinkopanter
New install of VestaCP. NGINX and HTTPD can start after server reboot. I have to manually restart the services. I run chkconfig nginx on and chkconfig httpd on, but with no help.

Anyone?

Re: NGINX and HTTPD not starting at reboot

Posted: Tue Dec 27, 2016 4:48 pm
by damian.lavalle
Actually, I'm experiencing the same problem. And it's not just after reboots, it happens on it's own, possibly right after automatic updates. Anyone else have this issue? When I fist saw it I though it could be a problem with multiple applications attempting to control a single port. Port 80 to be specific. Like Apache has a default config attemtping to grab port 80 while Ngenix is wants that port too. As a result neither start. BUT that's just a guess.

Re: NGINX and HTTPD not starting at reboot

Posted: Wed Dec 28, 2016 2:06 am
by dpeca
Try to add to /etc/rc.local these lines:

Code: Select all

sleep 3
service nginx restart
service nginx httpd

Re: NGINX and HTTPD not starting at reboot

Posted: Fri Dec 30, 2016 5:35 pm
by Trentor
============================================================================================

nginx

1.Edit nginx service:

Code: Select all

nano /etc/systemd/system/multi-user.target.wants/nginx.service
2. Change this:

Code: Select all

After=nss-lookup.target remote-fs.target
To this:

Code: Select all

After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
============================================================================================

Apache

1. Edit apache service (modify "httpd" for your Apache name service):

Code: Select all

nano /etc/systemd/system/multi-user.target.wants/httpd.service


2. Do the same changes as nginx.

============================================================================================

Reboot your server.

Re: NGINX and HTTPD not starting at reboot

Posted: Sun Mar 26, 2017 6:22 am
by drcrash
Trentor wrote:============================================================================================

nginx

1.Edit nginx service:

Code: Select all

nano /etc/systemd/system/multi-user.target.wants/nginx.service
2. Change this:

Code: Select all

After=nss-lookup.target remote-fs.target
To this:

Code: Select all

After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
============================================================================================

Apache

1. Edit apache service (modify "httpd" for your Apache name service):

Code: Select all

nano /etc/systemd/system/multi-user.target.wants/httpd.service


2. Do the same changes as nginx.

============================================================================================

Reboot your server.
Thanks! It worked for me, but after this changes i got error when trying to restart httpd:
[root@web]# service httpd restart
env: /etc/init.d/httpd: Permission denied

and file /etc/init.d/httpd and /etc/rc.d/init.d is empty (CentOS 7)

may be i do some thing else

when i rebooting the server all starts ok, bun not restarting. start and stop httpd not working too :(

command systemctl restart httpd works fine

Re: NGINX and HTTPD not starting at reboot

Posted: Mon Mar 27, 2017 10:18 am
by vikhyat
try rebuilding all users.

and post output of this command

Code: Select all

nginx -t -c /etc/nginx/nginx.conf

Re: NGINX and HTTPD not starting at reboot

Posted: Tue Mar 28, 2017 3:56 pm
by drcrash
vikhyat wrote:try rebuilding all users.

and post output of this command

Code: Select all

nginx -t -c /etc/nginx/nginx.conf
I rebuild all users and still have problem with HTTPD service

Code: Select all

[root@web ~]# nginx -t -c /etc/nginx/nginx.conf
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Re: NGINX and HTTPD not starting at reboot

Posted: Sun Apr 02, 2017 6:02 pm
by drcrash
Can anyone show /etc/rc.d/init.d/httpd for centos 7, apache 2.4.6?
mine is empty :(

Re: NGINX and HTTPD not starting at reboot

Posted: Sun Apr 02, 2017 6:58 pm
by skamasle
Centos 7 use systemd so you not have /etc/init.d/httpd this is not used

Re: NGINX and HTTPD not starting at reboot

Posted: Wed Jun 02, 2021 9:23 am
by lex0013
dpeca wrote:
Wed Dec 28, 2016 2:06 am
Try to add to /etc/rc.local these lines:

Code: Select all

sleep 3
service nginx restart
service nginx httpd
Yes, it works wonderfully for Centos 8
Can be executed on the command line.

Code: Select all

echo "sleep 3 && systemctl restart nginx  && systemctl restart httpd" >> /etc/rc.local