skip to Main Content

Our application is hosted on Linux server Apache/2.4.6 (CentOS)
Whenever the system reboots we have to manually start Apache service.
We want to automate this process such that on every reboot these services start automatically.

Also we have to run few mysql queries manually to update SQL_MODE variable on system reboot. Please guide us to automate this as well.

2

Answers


  1. In order to start automaticly apache/mysql on boot:

    sudo update-rc.d apache2 enable
    sudo update-rc.d mysql enable
    

    Otherwise with cron jobs :

    crontab -e
    

    then add:

    @reboot systemctl start apache2.service
    @reboot systemctl start mysql.service
    

    For your mysql queries, you can use also “@reboot” and code your queries for example with pyhton:

    @reboot /usr/bin/python path/to/your/script/containing/queries.py
    

    In some Linux distros, you have to write “httpd” instead of “apache2”.

    Login or Signup to reply.
  2. Considering you are trying to install apache on CENTOS 7, you can try to enable the service using below command :

    sudo systemctl enable httpd

    This article from DigitalOcean is a good read in same regards :- https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-centos-7

    For MySQL issue, it would be worth checking below article where the author speaks on setting parameters in /etc/mysql/my.cnf in [mysqld] section.

    setting global sql_mode in mysql

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search