域名备案查询
主办单位:
单位性质:
备案号:
网站名称:
网站首页:
审核时间:
最近检测:
[Unit]
Description=WebSocket PHP Service
After=network.target
[Service]
Type=simple
# 请替换为您的PHP解释器路径和脚本绝对路径
ExecStart=/www/server/php/74 /www/wwwroot/home/server.php
[Install]
WantedBy=multi-user.target
# 重新加载 systemd 配置
sudo systemctl daemon-reload
# 启用服务,使其在系统启动时自动运行
sudo systemctl enable webSocket-php-service.service
# 立即启动服务(可选)
sudo systemctl start webSocket-php-service.service
[Unit]
Description=My PHP Service
After=network.target
[Service]
Type=simple
ExecStart=/www/server/php/74 /www/wwwroot/home/server.php
WorkingDirectory=/www/wwwroot/home/
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
[Unit]
Description=My PHP Command Service
After=network.target
[Service]
ExecStart=/usr/local/php/bin/php /www/wwwroot/home/server.php start
WorkingDirectory=/www/wwwroot/home
Restart=always
[Install]
WantedBy=multi-user.target
cd /www/wwwroot/home/websocket
php chat_server.php
nohup php chat_server.php > logs/chat.log 2>&1 &
# Supervisor配置示例
[program:websocket_chat]
command=php /www/wwwroot/home/websocket/chat_server.php
directory=/www/wwwroot/home/websocket
autostart=true
autorestart=true
user=www
redirect_stderr=true
stdout_logfile=/www/wwwroot/home/websocket/logs/websocket.log