Writing an operating system is a huge task on a modern PC, just talking to the hardware would require a huge amount of indepth knowledge, chnage once pice of kit on it and you are back a square one.
Way way to big for someone asking the question.
Start simple a PIC micro or an 8 bit or something. Coding is going to be assembler or C/Pascal at the highest, for bootstrapping, loading the os itself.
A webserver well that's a bit more achievable, you need to find out how they work now, HTTP, HTML.
Either way first thing you need to do is read, a lot.
This is going to sound brutal but the fact that you came on here and asked the question means you don't have a prayer at the moment.
I've been coding for over thirty years, and I'd have to spend six months to a year, just come up with a vague plan.
If insist on jumping in at the deepend, look up lilo or grub, MBR, bootstrapping, TinyLinux might give you a lot of clues.
on the OS front to start getting a handle in the issues.
Webserverwise, Apache is a bit big, but there at least used to be savant and nginx, again get a feel for the basics.
Have fun.