Apache – reliable and flexible HTTP web server

Apache - reliable and flexible HTTP web server 1

To begin with, by clarifying what the Web Server is. Web server – a program running on a local or remote machine. Its main purpose is to allow the user to view web documents. When the site address is entered in the address bar, press Enter, the browser generates a request. It is sent to a remote computer – a web server.

This web server dates back to 1995. It is believed that it comes from “a patchy”. It was designed to correct errors and adjust the operation of the then popular HTTPd 1.3 server. This flexible web server is maintained and developed by an open community of developers under the symbolic name “Apache Software Foundation”.

Since April 1995, it has already been considered the most reliable and popular HTTP server in the entire Internet space. It is also interesting that in 2016 it was serviced by more than 305 million sites. View current versions, download links for this web server. As well as more information about this very flexible and reliable server can be found here.

In this day, this web server serves the work of sites and provides a load of about 46% of all sites in the world. This server provides quality service for content on the sites of all users. When someone wants to visit the site, he writes the domain name in the address bar of his browser. The web server then delivers the requested files as a virtual messenger.

When any visitor to your site wants to download a page (for example, the “about us” page on hostry.com). Its browser sends a request to your server. Then Apache returns a response with absolutely all the requested files from this site. It can be pictures, text animation. The server and client communicate via HTTP. This server is responsible for the operation, flexibility, secure connection and reliability between two computers.

Advantages and disadvantages of choosing this server

This web server has its advantages and also some disadvantages compared to other web servers. We would like to describe them below for your reference:

Advantages

  • This reliable server is absolutely free for commercial use. If you have plans to build a small budget project, then this web server is ideal for you!
  • It is very flexible and has stable software;
  • Apache HTTP web server is updated very often, security patches come out regularly;
  • Works for sites on the WordPress platform immediately after installation, and there is no need to configure additional settings.
  • Very easy to set up

Disadvantages

  • If you have entered too many configuration parameters for this web server, then this may lead to small security vulnerabilities;
  • There may also be some performance issues on sites with high enough traffic.

Apache HTTP web server also has the advantages that it works great and is compatible with many other systems, such as Joomla, Drupal and other content management systems. This makes this web server a very confident solution for you in working with these systems.

Linux Apache Web Server Configuration

We’ll provide a short guide below on how to configure this flexible and highly reliable web server. Apache configuration for all virtual hosts is determined using a single file – /etc/httpd/conf/httpd.conf (this is the case when it comes to configuration on OSs such as CentOS, CloudLinux, Red Hat Enterprise Linux). Or the file /etc/apache2/apache2.conf, which is applicable on Debian and Ubuntu respectively.

Virtual server configuration files are at the lowest level of the configuration file hierarchy. They get into the Apache configuration file (last_httpd.conf) through several levels of inclusion using the include directive.

Nginx uses a similar approach: the /etc/nginx/nginx.conf file contains configuration files. They are available in all virtual servers with several levels of inclusion. It is very important to know about the hierarchy of Apache configuration servers. For more information, we offer you the following link.

Each virtual server should have two files – last_httpd.conf and last_nginx.conf. They define the standard configuration of Apache and nginx for the corresponding virtual server. These files are always located in the /var/www/vhosts / system/<domain name>/ conf/ folder. Then created automatically based on the so-called configuration templates.

Working with the Apache HTTP web server

After you have installed this web server (apt install apache) and indicated the need to automatically start the httpd service when the system starts, you can additionally test it. You need to enter “http://server ip-address/” in absolutely any browser. It is advisable to manage your running web server with the following directives:

service httpd status

The following directive will show you a list of running web server processes. Inform you that the web server has not been loaded:

service httpd stop; service httpd start

The following directive stops and then immediately starts the main web server process:

service httpd restart

Configure firewall to allow traffic

Based on the fact that this server has already been started, the following is necessary to enable the UFW firewall. The first thing to do is make sure that UFW has a profile for Apache:

sudo ufw app list

Next will be the following conclusion:

Available applications:
  Apache
  Apache full
  Apache secure
  Openssh

After that, you need to check the configuration of the Apache Full profile (traffic should be allowed for ports 80 and 443):

sudo ufw app info "Apache Full"

The following output will be shown:

Profile: Apache Full
Title: Web Server (HTTP, HTTPS)
Description: Apache v2 is the next generation of the omnipresent Apache web
server.

Ports:
  80,443 / tcp

Next, we allow incoming HTTP and HTTPS traffic for this profile:

sudo ufw allow in "Apache Full"

We check the result by entering the following into the search browser browser:

http://your_server_IP_address

Optimization of the Apache web server

This flexible and realible web server is very productive. It offers a fairly large number of modules. It is great for deploying new projects – you can set up a reliable manufacturing environment with it. As your project grows, there may be problems, and the first thing that will be described is disabling unnecessary modules.

Disabling unnecessary modules

On operating systems such as Debian and Ubuntu- there are directories /etc/apache2/mods-enabled and /etc/apache2/mods-available/. The latter contains a list of all modules installed on this server. And in the mods-enabled directory are the modules that are currently enabled.

The first is to save the list of modules that are active by default so that you can later use it to restore default settings. After that, you can simply disable all unnecessary modules one at a time, restarting Apache after disabling each module to make sure that no errors have occurred in the system.

In Ubuntu and Debian, these modules can be disabled using the following command:

sudo a2dismod autoindex

We also want to note: for example, one child process in the Apache HTTP web server can take up to 80-100 MB of RAM. If you plan to launch a large project, which is likely to grow later, we recommend tariffs with availability of 4GB RAM or more! This will help you maintain balance in server load!

Alternative mpm configurations

Very often, Apache realible configurations use the prefork mpm configuration. It is considered safe and suitable for PHP and other languages. However: if you get rid of external modules, you can also consider worker MPM as a good alternative. To enable this module, enter the following: