This depends drastically based on the operating system and web server application in question. For a Windows IIS server, sometimes the software comes pre-installed. The same is true of certain Java machines or Linux machines, which might come pre-installed with Apache.
Some web servers can be installed via command line in programming languages/interfaces like Python or NodeJS. Ruby on Rails usually comes with Mongrel or Passenger, and almost every programming language will have a most commonly used web server. Each one will require special installation and appreciation of web ports.