How to install on Debian 10 Linux Apache Web Server

Apache HTTP Server is one of the world's most popular Web server. It is an open source HTTP server and cross-platform support for most Internet sites. Apache provides many powerful features, it can be extended by other modules.

In this tutorial, we will explain how to install Apache on Debian 10, Buster.

prerequisites

Before starting the tutorial, make sure you log in as a user with sudo privileges.

Installing Apache

Apache software packages available in the default Debian repository.

Installation is very simple. Use the following command to update the package and install Apache Web server index:

sudo apt update
sudo apt install apache2

Is this, Apache has been installed and automatically activated. To check the status type:

sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: 
   Active: active (running) since Sat 2019-07-27 13:55:49 PDT; 21s ago
   ...

Adjust the firewall

UFW user may open the HTTP (80) and HTTPS (443) by enabling 'Apache Full' Port Profile:

sudo ufw allow 'Apache Full'

If the filter is connected to the system nftables, open the necessary ports by issuing the command:

nft add rule inet filter input tcp dport {80, 443} ct state new,established counter accept

Verify Apache installation

To verify whether Apache is working properly, open the browser, type the IP address or domain name server http: // YOUR_IP_OR_DOMAIN /, you'll see the default Apache welcome page, as shown below:

This page contains information about the Apache configuration file, the basic information to help script and directory location.

Apache configuration file structure and best practices

  • Debian based systems, Apache configuration file located in / etc / apache2 directory.
  • The main Apache configuration file is /etc/apache2/apache2.conf.
  • Apache will listen on port specified in /etc/apache2/ports.conf file.
  • Apache Virtual Hosts file is located in / sites-available directory / etc / apache2. Unless the link to / etc / apache2 / sites-enabled directory, or does not use Apache configuration files in this directory found.
  • You can create a symbolic link by using a configuration file in sites-available directory by a2ensite sites-enabled directory in order to activate the virtual hosts in command. To disable virtual hosts, use the command a2dissite.
  • It is strongly recommended to follow the standard naming convention, for example, if your domain is mydomain.com domain configuration file, it should be named /etc/apache2/sites-available/mydomain.com.conf
  • Apache module for loading various configuration files located in / mods-available directory / etc / apache2. mods-available directory can be created by using a2enconf command / etc / apache2 / mods-enable symbolic link and use the Disable command to enable the configuration a2disconf directory.
  • Global configuration file store contains fragments in / etc / apache2 / conf-available directory. conf-available via / etc / apache2 / conf-enabled using a2enconf command to create a symbolic link. Of course, you can use a2disconf command to disable file directory.
  • Apache log files (the access.log and the error.log) located at / var / log / apache directory. We recommend the use of different access and error log files for each virtual host.
  • You can document root domain will be set to any desired location. The most common location webroot include:
    • /home/<user_name>/<site_name>
    • /var/www/<site_name>
    • /var/www/html/<site_name>
    • /opt/<site_name>

in conclusion

Installing Apache on Debian is a problem running a single command. After installation you can start deploying applications and Apache as the Web or proxy server.

Guess you like

Origin www.linuxidc.com/Linux/2019-08/159847.htm