Choose a different version or distribution
Introduction
Before we begin talking about how to install Apache Web Server on Debian 10, let's briefly understand – What is Apache Web Server?
The Apache Web Server is a widely used software that powers websites on the internet. It is a free and open-source platform known for its reliability and flexibility. Apache enables websites to serve web pages and content to users, making it an essential component of the online world.
With its strong security features and extensive customization options, Apache Web Server remains a popular choice for hosting websites. Its user-friendly interface and widespread community support make it an excellent solution for businesses and individuals alike.
In this tutorial, you will install Apache Web Server on Debian 10 Linux.
Advantages of Apache Web Server
- Reliability: Apache Web Server is renowned for its stability, ensuring your website remains accessible to users without unexpected downtime.
- Security: With robust security features and regular updates, Apache safeguards your website from potential threats and vulnerabilities.
- Flexibility: Apache offers extensive customization options, allowing you to tailor your server configuration to meet specific requirements.
- Community Support: Benefit from a vast community of users and developers who provide valuable assistance and resources for Apache.
- Performance: Apache's efficient architecture and optimization techniques enable fast and seamless delivery of web content to visitors.
Prerequisites to Install Apache Web Server on Debian 10
Make sure you are logged in as a user with sudo privileges before beginning the tutorial.
Install Apache
Apache packages can be found in the standard Debian repositories.
The installation process is rather simple. With the following commands, you can install Apache and update the package index:
sudo apt update
sudo apt install apache2
That is it. Apache has now been installed and launched automatically. To determine the status, use the following command:
sudo systemctl status apache2
Output
● 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
By enabling the “Nginx Full” profile, UFW users can open HTTP (80
) and HTTPS (443
) ports:
sudo ufw allow 'Apache Full'
If your system uses nftables to filter connections, run the command below to open the required ports:
nft add rule inet filter input tcp dport {80, 443} ct state new,established counter accept
Verifying Apache Installation
To check that Apache is working properly, open your browser, type your server's IP address or domain name http://YOUR_IP_OR_DOMAIN/
, and you should see the default Apache welcome screen, as seen below:
Basic details regarding the location of directories, helper scripts, and Apache configuration files are provided on this page.
Apache Configuration File’s Structure and Best Practices
- The
/etc/apache2
directory stores Apache configuration files on Debian-based systems. /etc/apache2/apache2.conf
is the main configuration file for Apache.- The
/etc/apache2/ports.conf
file lists the ports that Apache will listen to. - The
/etc/apache2/sites-available
directory contains Apache Virtual Hosts files. Unless they are linked to the/etc/apache2/sites-enabled
directory, Apache does not use the configuration files found in this directory. - By making a symlink with the
a2ensite
command from the configuration files located in thesites-available
directory to thesites-enabled
directory, you can activate a virtual host directive. Thea2dissite
command can be used to disable a virtual host. - Adhering to the standard naming practice is highly advised. For example, if your domain name is
mydomain.com
, the domain configuration file should be named/etc/apache2/sites-available/mydomain.com.conf
. - Configuration files that are used for loading various Apache modules are found in the
/etc/apache2/mods-available
directory. By using thea2enconf
command to create a symlink to the/etc/apache2/mods-enable
directory, configurations in themods-available
directory can be enabled, and they can be removed with thea2disconf
command. - The
/etc/apache2/conf-available
directory stores files containing parts of the global configuration. Use thea2enconf
command to create a symlink to/etc/apache2/conf-enabled
to enable files in theconf-available
directory, and thea2disconf
command to disable it. - The
/var/log/apache
directory contains the Apache log files (access.log
anderror.log
). It is recommended that each virtual host have its ownaccess
anderror
log files. - Your domain's document root directory can be adjusted to any location you like. Webroot is typically found in the following places:
/home/<user_name>/<site_name>
/var/www/<site_name>
/var/www/html/<site_name>
/opt/<site_name>
FAQs to Install Apache Web Server on Debian 10 Linux
Where is the Apache configuration file located in Debian 10?
The main configuration file for Apache in Debian 10 is located at /etc/apache2/apache2.conf
.
How can I start, stop, or restart Apache?
You can control Apache using the commands: sudo service apache2 start/stop/restart
.
How can I check if Apache is running?
Use the command: sudo service apache2 status
to check the status of the Apache service.
How can I enable or disable modules in Apache?
To enable a module, use sudo a2enmod <module_name>
. To disable, use sudo a2dismod <module_name>
.
Where should I place my website files?
By default, the web files are stored in the directory /var/www/html/
.
How can I access the Apache default page?
Open a web browser and type "http://localhost" or "http://<your_server_IP_address>".
How can I secure Apache with SSL/TLS?
Use the Apache module mod_ssl
and obtain an SSL certificate to enable secure connections with HTTPS.
Conclusion
In this tutorial, you installed the Apache Web Server on Debian 10 Linux.
If you have any queries, feel free to post a comment below and we'll be happy to answer them.