N
N
nezzard2016-12-10 14:58:00
PHP
nezzard, 2016-12-10 14:58:00

How to add php script to autoload in centos?

Good afternoon, there is a php script that needs to be automatically launched after a reboot, how can I add it to autoload?
And yet, is there a way to raise, reload the script if it freezes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Evseev, 2016-12-11
@IlyaEvseev

An easy way is to add a run command to /etc/rc.local:
Правильный способ - написать сервис для systemd:
1) создаёте файл /etc/systemd/system/myphp.service

[Unit]
Description = making network connection up
After = network.target
[Service]
ExecStart = /usr/bin/php -f /var/www/my.php
[Install]
WantedBy = multi-user.target

2) Make systemd read it: systemctl daemon-reload
3) Enable autostart: systemctl enable myphp
4) Запускаете: systemctl start myphp
5) Проверяете состояние: systemctl status myphp
Подробнее: https://habrahabr.ru/company/centosadmin/blog/255845/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question