Centos: Making sure your web services auto start after reboot

Your server had to restart, either by design or after some bad event, and now your website doesn’t work – “connection failure”.  Looks like your important web services are not set to start automatically on boot up.  Here is what to do to get your httpd and mysqld services running on restart.

You need to add the httpd (apache web server) and mysqld (mysql database) services to the chkconfig and then set them to autostart.

As a super user (su), or by using sudo, do the following:

Centos 6

  1. /sbin/chkconfig –add httpd
  2. /sbin/chkconfig httpd on
  3. /sbin/chkconfig –list httpd
  4. /sbin/chkconfig –add mysqld
  5. /sbin/chkconfig mysqld on
  6. /sbin/chkconfig –list mysqld

If for some reason you want to stop them from autostarting you can do this:

/sbin/chkconfig httpd off
/sbin/chkconfig mysqld off

Centos 7

  1. systemctl enable httpd
  2. systemctl enable mysqld

Note:  if your server is running mariadb you may need to use  mariadb.service  instead of mysqld

You can check the status of the service:

systemctl status httpd
systemctl status mysqld
systemctl status mariadb

Give your a server a reboot and, all being well, marvel at how everything just works straight away.



Facebook Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Apply your human brain cells and complete this highly complicated maths problem *