A web server is an application responsible for providing information in the form of web pages. In addition, he is responsible for many additional functions, including:
- execution of various applications written in PHP, ASP and other programming languages;
- support for secure connections using HTTPS;
- user authorization.
Major web servers
Today, the Apache web server is most popular due to its compatibility with a large number of operating systems and a free license.
Corporate users often use a similar product called Internet Information Services (IIS), developed by Microsoft.
In some cases, for example, if you need to increase the speed of returning static content or to use specific functions in the application, resort to the use of web servers Nginx, lighttpd and others.
Web Server Principles
Upon receiving a request from a user, the web server, depending on the type of file requested, sends it to the client or starts processing the page. In this case, a response code is generated, which indicates a successful operation or any errors.
In the process of processing the page, the web server, if necessary, runs a variety of scripts or applications, receives data from them and, after converting to the required form, sends it to the client. Most often, the result of the web server is pages that are decorated in HTML, which is displayed by the browser. There are other answer options, for example, for programs running on a user device, data in XML, JSON, and so on may come.
Assigning local web servers
When developing applications, any programmer is faced with the need for constant testing. Often for these purposes it is convenient to use a local web server, which is installed directly on the developer's computer. This is due to the ability to quickly make edits and the lack of the need for a permanent connection to remote machines.
You can check the appearance of HTML pages without additional software using the file open function. In this case, the browser will not execute the application, but simply displays all the text, observing the HTML markup. This can lead to the strangest results. To achieve the results corresponding to those that will be obtained when placing the resource on the Internet, allows the web server, which is installed on the local computer.
Developer packages or do-it-yourself web server installation and configuration
Most web servers are free and licensed. Paid products are rare and are usually required only in a corporate environment. Download and install the software on your own computer is not a problem. A more difficult step is tuning. The default web server is inconvenient for real use even during application testing. Therefore, you will have to edit several files to specify the necessary parameters.
Another approach is popular with Windows users. It consists in using application packages for developers. This kit immediately includes: a web server, MySQL database management system , various programming languages. In this option, after installation on the local computer, everything will be configured automatically.
The choice of installation option depends on the user's personal preferences and qualifications. In most cases, you can use the kit, although there may be outdated versions of programming languages or databases, which can greatly complicate the development and selection of a hosting provider to host a finished resource.
Installing a local web server on a virtual machine
A virtual machine allows you to run multiple instances of operating systems on a single computer. Moreover, they can even be from different families. For example, you can run Linux and FreeBSD from Windows.
Installing a web server for testing applications or sites on a virtual machine allows you to create a configuration that is as similar as possible to the real conditions in which the work will take place. Most modern hosting sites are running Linux, which leads to more specific software configurations. You can install the same operating system on a virtual machine, create a file structure as close to reality as possible, select the necessary versions of programming languages and database management systems. Another advantage is the ability to test several projects that require a wide variety of configurations.
There is also a drawback to the virtualization approach. The user will need to familiarize themselves with the documentation not only on setting up and installing the web server, as well as other programs, but also with the manuals for the operating system itself. To quickly configure virtual machines, you can also use special control panels that will automatically perform the installation and configuration of the web server and other applications.