“Linux LNMP 报错”是一个比较宽泛的问题,因为 LNMP(Linux + Nginx + MySQL/MariaDB + PHP) 在任何一环都可能出错。下面我按常见报错类型 + 原因 + 排查思路给你总结一下,你可以对照看看属于哪一种。
systemctl start nginx
Job for nginx.service failed
常见原因:
排查:
nginx -t
查看配置错误位置。
页面访问显示:
403 Forbidden
原因:
解决:
chown -R www:www /网站目录
chmod -R 755 /网站目录
访问 index.php 变成下载或 404
原因:
fastcgi_pass 地址错误示例配置:
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
systemctl start php-fpm
常见原因:
查看:
php-fpm -t
journalctl -xe
原因:
排查:
tail -f /var/log/php-fpm/error.log
tail -f /var/log/nginx/error.log
systemctl start mysqld
常见原因:
查看日志:
cat /var/log/mysqld.log
PHP 报错:
Access denied for user 'root'@'localhost'
原因:
systemctl enable nginx
systemctl enable mysqld
systemctl enable php-fpm
你可以按顺序检查:
nginx -t
systemctl status nginx
systemctl status php-fpm
systemctl status mysqld
df -h
free -h
如果你愿意,可以把具体报错内容发出来,例如:
我可以直接帮你精准定位并给解决方案。