Home>Article>PHP Framework> How to set workerman to start automatically after booting up (linux environment)

How to set workerman to start automatically after booting up (linux environment)

青灯夜游
青灯夜游 forward
2021-01-21 17:27:46 3806browse

This article will introduce to you the method ofworkermansetting up automatic startup on boot under Linux system. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to set workerman to start automatically after booting up (linux environment)

Related recommendations: "workerman Tutorial"

Step 1: Create the worker.service service file (Permission 755)

/lib/systemd/system/workerman.service

Step 2 : Copy the following code, save and exit. Pay attention to modify your worker path

## Path: /www/wwwroot/xxx.com/server.php

Start command: php server.php start

It can be started in the above command, the path is as follows

[Unit] Description=workerman After=network.target [Service] Type=forking ExecStart=/usr/bin/php /xxx/xxx/server.php start -d ExecReload=/usr/bin/php /xxx/xxx/server.php restart ExecStop=/usr/bin/php /xxx/xxx/server.php stop PrivateTmp=true RemainAfterExit=yes [Install] WantedBy=multi-user.target

To modify this file, you must restart the server, otherwise it will not take effect

Step 3: Start the service

systemctl start workerman.service

Step 4: Check the service status

systemctl status workerman.service

Step 5: Boot up

systemctl enable workerman.service

Note:


The pagoda does not work here. After the above is generated, a task will be generated here. Do not operate it

Error:

The unit file, source configuration file or drop-ins of workerman.service changed on disk. Run 'systemctl daemon-reload' to reload units

The workerman.service service file was modified without restarting the server

For more programming-related knowledge, please visit:

Introduction to Programming! !

The above is the detailed content of How to set workerman to start automatically after booting up (linux environment). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete