I have almost the same problem.
My RBP 3 with LAMP have trouble when I disconnect the keyboard from USB.
But in my case, RBP continues working except PHP. PHP pages stop working.
After three days testing conditions, I found that:
- when USB keyboard is attached, all work fine.
- when I disconnect keyboard (after smoothly shutdown RBP), and turn RBP on, PHP doesn´t work.
At this time, is working fine with keyboard connected, SSH putty, phpmyadmin, remote desktop, filezilla, webmin, all of them from internet, besides inside my LAN.
In my case, RBPi is booting without keyboard, but PHP doesn't work.
I don't know what it could be. I hope you can help me.
My RBP3 is configured with:
MariaDB (MySQL) 10.1.37
Debian version: 9.8
Kernel version: Linux raspberrypi2 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux