Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
170 views
in Technique[技术] by (71.8m points)

Linux can't find process started by PHP


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To create a service using systemd :

Create a file in /etc/systemd/system/ called minecraft-server.service with the following content:

[Unit]
Description=Minecraft server 
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
User=minecraft
Group=appmgr
ExecStart=java -Xmx4G -Xms4G -jar server.jar

[Install]
WantedBy=multi-user.target

Replace server.jar with full path.

Now lets create the new group and user.

To create new group run the following command:

sudo groupadd appmgr

Now lets create the new user and it it to a group.

sudo useradd –G appmgr minecraft

Now your service is created, we need to enable it and run it for first time.

systemctl enable minecraft-server
systemctl start minecraft-server

Last step to write php script to restart the services:

<?php 
    exec("systemctl restart minecraft-server");
?>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...