Question is a router required for setting up a local webserver?

Jan 20, 2019
i'm trying to set up a local webserver using Xampp, do i need to buy a router for my other computers to be able to connect to my local webserver?

is it really not possible to connect my webserver pc and laptop pc together using just the Ethernet cable?

thanks for the help!
You are confused. Everybody already have a router, more specifically a WIFI router, the WIFI portion is not important to your web server but it just happens these two things are often in one box.

A router then is one's FIREWALL, and in order to operate a local server, you either use the router's DMZ feature if available and security not a concern, or "punch a hole" in the router via a function called Port Forwarding. This question is asked so often and so common I don't feel like regurgitating. Google "web hosting port forwarding."
I suspect there is more to your question that is apparent.

A router is really only a device that is needed if you need to leave your local network. In the simplest cases you can just plug the 2 devices together and they will work fine. If you need more than 2 device you need at least a small unmanned switch.

Still that is kinda a unrealistic case in today's world. You see software developers do it to test but who does not have any need for internet access.

Most people already have a router and the lan ports on the router act as a switch connecting all the internal machine together.
security wise you might want a different one. If you aren't sure look into paying for hosting.
If you want to DIY then I'd suggest spending some time researching the best practices and checking with your ISP to see if it's allowed. They might block it.
You don't need a router if all you want is to have a server accessed locally. If you want to connect more than two devices (server, laptop and desktop), you'll need an Ethernet switch. For two devices only, direct cable connection would be OK. In all cases, you need static IP addresses on all devices.