Debian PHP 服务恢复步骤
一 快速恢复流程
sudo systemctl restart apache2,随后 sudo systemctl status apache2sudo systemctl restart php<版本>-fpm,随后 sudo systemctl status php<版本>-fpmsudo systemctl restart php<版本>-fpm,再 sudo systemctl reload nginxsudo tail -f /var/log/php-fpm.logsudo tail -f /var/log/syslog/var/log/apache2/error.log 或 /var/log/nginx/error.loginfo.php,内容为 <?php phpinfo(); ?>,访问 http://服务器IP/info.php 确认页面正常。二 配置与语法快速检查
php -l /etc/php/<版本>/apache2/php.ini(路径中的 <版本> 按实际替换,如 7.4、8.2)php -l /var/www/html/index.phpmax_execution_time(建议不超过 30 秒)memory_limit(建议至少 128M)error_log(确保路径可写且正确)display_errors(生产环境建议 Off,避免暴露敏感信息)opcache(如怀疑异常,可先临时关闭再重启观察)三 按运行栈的恢复要点
sudo apt-get install libapache2-mod-php<版本>sudo a2enmod php<版本>;sudo systemctl restart apache2sudo apt-get install php<版本>-fpmfastcgi_pass 与 FPM 监听一致(如 unix:/var/run/php/php<版本>-fpm.sock;)sudo nginx -t;sudo systemctl reload nginxsudo a2disconf php<旧版本>-fpm,sudo a2enconf php<新版本>-fpm,然后重启对应服务。四 无法启动时的应急与修复
php.ini 或 FPM 池配置还原;必要时用 apt-get --reinstall install php<版本>-fpm 重装sudo journalctl -xe -u php<版本>-fpm 获取单元启动失败原因free -h、df -h;排查进程异常 ps aux | grep phpsudo reboot 清理可能的内存/缓存问题。