Turn a Android Phone with broken screen into dedicated Web server
Welcome to the Android Enthusiasts, Majk! We support end-users with Android-specific issues, but cannot help you setting up a Linux server on a device, though it was running Android before. Still, some helpful hints:


There are means to control your device even with a broken screen. We've got several issues reported where people wanted to do exactly that. Please check e.g.:


My screen got broken, how to see on the computer what I'm doing in my device?
Control Android with broken screen from PC
Use android phone with broken screen as WiFi camera
Broken Screen + Using adb shell to run vnc server

There are several web server apps available for Android as well. Even some supporting/including things like PHP and MySQL. Some examples:


AndroPHP
Ulti Server: PHP, MySQL, PMA
KSWEB: server + PHP + MySQL
NAMP nginx android web server



I guess that should get you started if you want to solve your issue using Android. And as I initially wrote: Doing that with any other OS, even on an "Android device", is beyond the scope of this site. But I would wonder if you will really need that, after these details – right? :)