Debian 上“进程启动失败”原因很多,一般按下面思路一步步排查最快。
不要只说“启动失败”,先确认:
查看服务失败原因:
systemctl status 服务名
journalctl -xe
journalctl -u 服务名
报错类似:
Permission deniedcannot open ...解决:
# 查看权限
ls -l /path/to/file
# 给执行权限
chmod +x /path/to/file
# 服务通常以特定用户运行
# 检查 systemd 里 User= 是否正确
报错:
Address already in use查看:
ss -lntp
lsof -i:端口号
处理:
报错:
command not foundNo such file or directorylibxxx.so not found解决:
# 查找缺什么
ldd 程序路径
# 安装依赖
apt update
apt install 缺的包
常见于自己写 .service 文件
检查:
systemctl daemon-reload
systemctl restart 服务名
.service 示例(常见坑):
[Service]
ExecStart=/usr/bin/python3 /opt/app.py
WorkingDirectory=/opt
User=appuser
Restart=on-failure
注意:
ExecStart 必须是绝对路径Environment=直接运行看报错:
/usr/bin/你的程序
如果是 Python:
python3 app.py
df -h
free -h
把下面内容贴出来:
cat /etc/os-release)例如:
Debian 12,nginx 启动失败
Job for nginx.service failed
bind() to 0.0.0.0:80 failed
我可以直接告诉你怎么改。