Introduction
Apache HTTP server is the most widely used web server in the world. It provides many powerful features including dynamically loadable modules, strong media support, and extensive integration with other popular software.
In this guide, we will explain how to install an Apache web server on your Debian 10 server.
previous requirements
Before starting this guide, you should have a normal non-root user with sudo privileges configured on your server. Also, you will need to enable a basic firewall to block non-essential ports. You can learn how to set up a regular user account and set up a firewall for your server by following ourinitial server setup guide for debian 10.
Once you have an account available, log in as your non-root user to get started.
Step 1: Installing Apache
Apache is available in the standard Debian software repositories, which allows it to be installed using conventional package management tools.
Let's start by updating the local package index to reflect the latest upstream changes:
- sudo fitupdate
Then install theapache2
package:
- sudo fit installapache2
After confirming the installation,fit
it will install apache and all necessary dependencies.
Step 2: Adjust the firewall
Before trying Apache, you should modify your firewall settings to allow external access to standard web ports. Assuming you've followed the prerequisite instructions, you should have a UFW firewall configured to restrict access to your server.
During installation, Apache registers with the UFW to provide some application profiles that can be used to enable or disable access to Apache through the firewall.
enumerate theufw
application profiles by typing:
- sudoufw app list
You will see a list of application profiles:
Salida
Available applications: AIM Bonjour CIFS. . . WWW WWW Full WWW Cache Secure WWW. . .
Apache profiles begin with WWW:
- WWW: This profile only opens port 80 (normal, unencrypted web traffic)
- Hidden- This profile only opens port 8080 (sometimes used for caching and web proxies)
- full www: This profile opens port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)
- insurance www: This profile only opens port 443 (TLS/SSL encrypted traffic)
We recommend enabling the most restrictive profile which will continue to allow the traffic you configured. Since we haven't configured SSL for our server yet in this guide, we'll only need to allow traffic on port 80:
- sudough let me'WWW'
You can verify the change by typing:
- sudoufw status
You should see the allowed HTTP traffic in the displayed output:
Salida
Status: activaPara Acción Since-- ------ ----OpenSSH ALLOW AnywhereWWW ALLOW AnywhereOpenSSH (v6) ALLOW Anywhere (v6)WWW (v6) ALLOW Anywhere (v6)
As you can see, the profile has been activated to allow access to the web server.
Step 3: Checking your web server
At the end of the installation process, Debian 10 starts Apache. The web server should now be up and running.
check with himsystem
init to make sure the service is running by typing:
- sudosystemctl status apache2
Salida
● apache2.service: The Apache HTTP server Loaded: Loaded (/lib/systemd/system/apache2.service; enabled; Vendor default: enabled) Active: active (running) since 7/19/2019 3:33 AM :01 p.m. m. UTC ; 4 min 13 s ago Docs: https://httpd.apache.org/docs/2.4/. . Jul 19 3:33:01 debssh systemd[1]: Starting Apache HTTP server... Jul 19 3:33:01 debssh apachectl[2791]: AH00558: apache2: could not reliably determine hostname full server domain, using 127.0. 1.1. Set directive 'ServerName' globalJul 19 15:33:01 debssh systemd[1]: Started Apache HTTP server.
As you can see in this output, the service appears to have started successfully. However, the best way to test this is to request an Apache page.
You can access Apache's default home page to confirm that the software is running correctly through your IP address. If you don't know the IP address of your server, you can get it in different ways from the command line.
Try typing this at your server's command prompt:
- host name -UE
You will get some addresses separated by spaces. You can try each one in your web browser to see if they work.
An alternative is to use thecurling
tool, which is supposed to give you your public IP address as seen from anywhere else on the Internet.
First, installcurling
usingfit
:
- sudo fit install curling
so usecurling
recovericanhazip.comusing IPv4:
- curling -4icanhazip.com
Once you have your server's IP address, enter it in your browser's address bar:
http://your_server_ip
You should see the Debian 10 Apache default web page:
This page indicates that Apache is working correctly. It also includes basic information about important Apache files and directory locations.
Step 4: Manage the Apache process
Now that you have your web server up and running, let's look at some basic administration commands.
To stop your web server, type:
- sudosystemctl parar apache2
To start the web server when it is stopped, type:
- sudosystemctl iniciar apache2
To stop and start the service again, type:
- sudosystemctl reiniciar apache2
If you are simply making configuration changes, Apache can reload without breaking connections. To do this, use this command:
- sudosystemctl recargar apache2
By default, Apache is configured to start automatically when the server starts. If this is not what you want, disable this behavior by typing:
- sudosystemctl desavar apache2
To re-enable the service to start at startup, type:
- sudosystemctlto allowapache2
Apache should now start automatically when the server is restarted.
Step 5: Configuring virtual hosts (recommended)
When using Apache web server, you can usevirtual hosts(similar to server blocks in Nginx) to encapsulate configuration details and host more than one domain from a single server. In the following commands,to replace your domain
with your own domain name. For more information on how to set up a domain name with DigitalOcean, please see ourIntroduction to Digital Ocean DNS.
Apache on Debian 10 has a server block enabled by default which is configured to serve/var/www/html
directory. While this works fine for a single site, it can get cumbersome if you host multiple sites. instead of modifying/var/www/html
, we are going to create a directory structure inside/var/www
for usyour domain
local, leaving/var/www/html
in effect, as the default directory to be served if a client's request does not match any other site.
Create the directory foryour domain
as follows, using the-page
flag to create the required parent directories:
- sudo mkdir -page/var/www/your domain
Then assign ownership of the directory with the$USER
environmental variable:
- sudo Chon -R $USER:$USER/var/www/your domain
Your web root permissions should be correct if you have not modified yourunmask
value, but you can be sure by typing:
- sudo chmod -R 755/var/www/your domain
Then create a sampleindex.html
page usingnano
your favorite editor:
- nano/var/www/your domain/index.html
Inside, add the following sample HTML:
/var/www/seu_dominio/index.html
<html> <head> <title>Bienvenido ayour domain!</title> </head> <body> <h1>¡Éxito! Oyour domainvirtual server is working!</h1> </body></html>
Save and close the file when finished.
In order for Apache to serve this content, you must create a virtual host file with the correct directives. Instead of modifying the default configuration file located at/etc/apache2/sitios-disponibles/000-default.conf
directly, let's make a new one in/etc/apache2/sites-available/your domain.conf
:
- sudo nano/etc/apache2/sites-available/your domain.conf
Paste the following configuration block, which is similar to the default but updated for our new directory and domain name:
/etc/apache2/sitios-disponibles/su_dominio.conf
<Virtual Host *:80> Server Manageradmin@your_email_domainserver nameyour domainServerAliaswww.your_domainDocumentRoot /var/www/your domainErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combinado</VirtualHost>
Please note that we have updated thedocument root
to our new directory andserver administrator
to an email thatyour domain
site administrator can access. We also add two directives:server name
, which sets the base domain that should match this virtual host definition, andServerAlias
, which defines other names that must match as if they were the base name.
Save and close the file when finished.
Let's enable the file with thea2ensite
tool:
- sudoa2ensiteyour domain.conf
Disable the default site set to000-default.conf
:
- sudoa2dissite 000-default.conf
Next, let's test the configuration errors:
- sudoapache2ctl configuration test
You should see the following output:
Salida
AH00558: Apache2: Cannot reliably determine the fully qualified domain name of the server using 127.0.1.1. Set the 'ServerName' directive globally to suppress this messageSyntax OK
Restart Apache to implement your changes:
- sudosystemctl reiniciar apache2
Apache should now be serving your domain name. You can test this by navigating tohttp://your domain
, where you should see something like this:
Step 6: Familiarize yourself with important Apache files and directories
Now that you know how to administer the Apache service, take a few minutes to familiarize yourself with some important directories and files.
Feliz
/var/www/html
: The actual web content, which by default consists only of the default Apache page you saw earlier, is served outside of/var/www/html
directory. This can be changed by changing the Apache configuration files.
server settings
/etc/apache2
: The Apache configuration directory. All Apache configuration files reside here./etc/apache2/apache2.conf
: The main Apache configuration file. This can be modified to make changes to the global Apache configuration. This file is responsible for loading many of the other files in the configuration directory./etc/apache2/ports.conf
: This file specifies the ports on which Apache will listen. By default, Apache listens on port 80 and additionally listens on port 443 when a module that provides SSL capabilities is enabled./etc/apache2/sites-available/
: The directory where the virtual hosts per site can be stored. Configuration files in this directory will not be used by Apache unless they are linked tosite enabled
directory. Usually all configuration of the server block is done in this directory and then enabled by linking to the other directory with thea2ensite
domain./etc/apache2/enabled sites/
: The directory where the virtual hosts enabled for the site are stored. They are usually created via links to configuration files found in theavailable sites
directory with thea2ensite
. Apache reads the configuration files and links found in this directory when it starts or reloads to create a complete configuration./etc/apache2/conf-disponible/
,/etc/apache2/conf-enabled/
: These directories have the same relationship as theavailable sites
misite enabled
directories, but they are used to store configuration fragments that do not belong to a virtual host. files inconf-available
The directory can be activated with thea2enconf
command and deactivated with thea2disconf
domain./etc/apache2/mods-disponible/
,/etc/apache2/mods-enabled/
: These directories contain the available and enabled modules, respectively. files ending in.carry
contain fragments to load specific modules, while files ending in.conf
contains the configuration for these modules. Modules can be enabled and disabled using thea2enmod
mia2dismod
domain.
server logs
/var/log/apache2/access.log
: By default, all requests to your web server are logged to this log file unless Apache is configured to do otherwise./var/log/apache2/error.log
: By default, all errors are logged to this file. EITHERlog level
The directive in the Apache configuration specifies how much detail the error logs will contain.
Conclusion
Now that you have your web server installed, you have many options for the type of content you can serve and the technologies you can use to create a richer experience.
If you want to build a more complete application stack, check out this article onhow to set up a LAMP stack on Debian 10.
FAQs
How to install Apache on Debian 10? ›
- Step 1: Update and install Apache. Run the following command to open the terminal and update the repository: `# sudo apt update` ...
- Step 2: Verify the installation. Run the following command: `# sudo systemctl status apache2` ...
- Step 3: Access Apache. ...
- Add firewall rules. ...
- Step 5: Verification.
- Installing Apache. To install Apache, install the latest meta-package apache2 by running: sudo apt update sudo apt install apache2. ...
- Creating Your Own Website. By default, Apache comes with a basic site (the one that we saw in the previous step) enabled. ...
- Setting up the VirtualHost Configuration File.
- Open terminal application on your Linux, Windows/WSL or macOS desktop.
- Login to remote server using the ssh command.
- To see Apache version on a Debian/Ubuntu Linux, run: apache2 -v.
- For CentOS/RHEL/Fedora Linux server, type command: httpd -v.
Installing a webserver
To install the default Debian web server environment under Debian, you should use tasksel, then select Web Server. If you wonder what's the content of that task, run tasksel --task-packages web-server (Of course, you need to have tasksel installed).
Active Configuration Files
Debian stores its Apache 2.0 configuration files in the directory /etc/apache2 . Normally the main Apache configuration file is called httpd. conf . Although that file exists on Debian, it is only there for compatibility with other software that expects it to exist.
- Download the installation media in the form of a ZIP file.
- Extract the contents of the Apache Web Server 2.4 zip to the file system.
- Locate the extracted Apache24 folder and copy this folder to the root of C:\
- Open the C:\Apache24\bin folder and run the httpd.exe command.
- Installing UFW.
- Checking UFW Status.
- UFW Default Policies.
- Application Profiles.
- Allow SSH Connections.
- Enable UFW.
- Opening Ports. Open port 80 - HTTP. Open port 443 - HTTPS. Open port 8080.
- Opening Port Ranges.
Step 1 — Installing Apache
Then, install the apache2 package: sudo apt install apache2.
- Create a file at /etc/httpd/conf. d/yourdomain.com. conf and add the following lines to it. ...
- Create a directory for the website and then create index. html file for the website. ...
- Add some content to index. html . ...
- Restart Apache service for the above changes to take effect. # systemctl restart httpd.
To test that an Apache HTTP server is working: From the local system, direct a browser on the local system to http://localhost . From a remote system, direct a browser to http:// followed by the value of the ServerName directive specified in the configuration file ( /etc/httpd/conf/httpd.
How do I add a repository to Debian 10? ›
You can add a package repository to Debian 2 ways from the shell: manually or using apt. The package repository information is stored in the file named /etc/apt/sources. list . And also can be stored in any file inside the directory /etc/apt/sources.
How to enable virtual host in Apache Debian? ›On Debian systems, Apache Virtual Hosts configuration files are located in /etc/apache2/sites-available directory and can be enabled by creating symbolic links to the /etc/apache2/sites-enabled directory, which is read by Apache during the startup.
How do I install and configure OpenLDAP server on Debian 10? ›- Step 1 - Update all packages. ...
- Step 2 - Install OpenLDAP package. ...
- Step 3 - Set password for slapd. ...
- Step 4 - Verify install of slapd. ...
- Step 5 - Edit directory domain.
- /etc/apache2/httpd. conf.
- /etc/apache2/apache2. conf.
- /etc/httpd/httpd. conf.
- /etc/httpd/conf/httpd. conf.
All the configuration files for Apache are located in /etc/httpd/conf and /etc/httpd/conf. d . The data for websites you'll run with Apache is located in /var/www by default, but you can change that if you want.
What is the latest version of Apache HTTP server? ›Original author(s) | Robert McCool |
---|---|
Initial release | 1995 |
Stable release | 2.4.55 / 17 January 2023 |
Repository | svn.apache.org/repos/asf/httpd/httpd/ |
Written in | C, XML |
Webmin, also known as Debian GUI (Debian Graphical User Interface), is a web based interface to manage and administer a Linux system. It provides a graphical user interface that can be used remotely via the Web browser and on terminal consoles.
Can you use apt-get on Debian? ›apt-get is a tool to automatically update your Debian machine and get and install debian packages/programs! This tool is a part of the DebianPackageManagement system.
Does Debian have a server? ›Debian and Ubuntu are used both as a desktop OS and a server. They are two of the most popular Linux distributions in history.
Where are packages installed in Debian? ›Debian already comes with pre-approved sources to get packages from and this is how it installs all the base packages you see on your system (if a user did a net-install). On a Debian system, this sources file is the "/etc/apt/sources.
How do I know if my Apache server is running? ›
Check if Apache is running on Windows
After pressing Ctrl + Shift + Esc, start typing either "httpd.exe" or "apache.exe" and see if they appear on the list. If they do, then Apache is running.
- In your Command Prompt window, enter (or paste) the following command: httpd.exe -k install -n "Apache HTTP Server"
- From your Command Prompt window enter the following command and press 'Enter.
- Restart your server and open a web browser once you are logged back in.
Apache is a freely available Web server that is distributed under an "open source" license. Version 2.0 runs on most UNIX-based operating systems (such as Linux, Solaris, Digital UNIX, and AIX), on other UNIX/POSIX-derived systems (such as Rhapsody, BeOS, and BS2000/OSD), on AmigaOS, and on Windows 2000.
Does Debian come with ufw? ›Debian does not install UFW by default. If you followed the entire Initial Server Setup tutorial, you will have installed and enabled UFW. If not, install it now using apt : sudo apt install ufw.
What is the default firewall in Debian 10? ›nftables is the default and recommended firewalling framework in Debian, and it replaces the old iptables (and related) tools.
How to install firewall in Debian 10? ›- UFW Installation ...
- UFW Uninstallation ...
- Enable UFW ...
- Checking the Status and Rules of the UFW ...
- Configuring UFW Default Policies ...
- Managing UFW Application Profiles ...
- Enabling IPv6 ...
- Allow SSH Connections
- Step 1: Install PuTTY and Log In. After you've acquired your VPS solution, you will need to install an SSH client to access it. ...
- Step 2: Install Apache. You can install Apache easily using CentOS's package manager, yum. ...
- Step 5: Configure Apache to Start on Boot.
"httpd" is the name of the deamon/service that runs in the background and processes all requests. "Apache Web Server" is the name of the software, which includes httpd.
How to install Apache in Linux using yum? ›- Enter the following command: # yum install httpd.
- Start the server, and configure it to start after system reboots: # service httpd start # chkconfig httpd on.
- Check for configuration errors: # service httpd configtest.
- Restart Apache 2 web server, enter: # /etc/init.d/apache2 restart. $ sudo /etc/init.d/apache2 restart. ...
- To stop Apache 2 web server, enter: # /etc/init.d/apache2 stop. ...
- To start Apache 2 web server, enter: # /etc/init.d/apache2 start.
How do I know if httpd is installed on Linux? ›
- Run the service httpd status command to confirm httpd is not running: ...
- Run the semanage port -l | grep -w http_port_t command to view the ports SELinux allows httpd to listen on: ...
- Edit /etc/httpd/conf/httpd.conf as the root user.
Starting httpd using the apachectl control script sets the environmental variables in /etc/sysconfig/httpd and starts httpd. You can also set the environment variables using the init script. You can also start httpd using /sbin/service httpd start. This starts httpd but does not set the environment variables.
How do I update Debian 10 packages? ›- Ensure that the system has been backed up.
- Update the existing Debian packages by running the command: apt-get update && apt-get upgrade. ...
- Using a text editor, edit the following file: ...
- Update the packages index by runnind the command: sudo apt update.
A Debian repository is a set of Debian packages organized in a special directory tree which also contains a few additional files containing indexes and checksums of the packages. If a user adds a repository to his /etc/apt/sources.
How to add sources in Debian? ›- Open the /etc/apt/sources.list file in any editor: $ sudo nano /etc/apt/sources.list.
- Add the VirtualBox repository in the file: ...
- Save and close the file.
- After adding the repository in the /etc/apt/sources.
- Step 1: Log in via SSH. ...
- Step 2: Change Logged in User Password. ...
- Step 3: Create a New Sudo User. ...
- Step 4: Logging in as the Newly Created User. ...
- Step 5: Disable Root Login via SSH. ...
- Step 6: Update Your Server. ...
- Step 7: Setting timezone. ...
- Step 8: Set Hostname.
- Step 1: Install kvm. ...
- Allow normal user to manage virtual machine. ...
- Step 2: Verify kvm installation on Debain. ...
- Step 3: Configure bridged networking on Debian. ...
- Step 4: Create your first virtual machine using an ISO image installer.
- Step 1: Make a Directory for Each Site. ...
- Step 2: Set Folder Permissions. ...
- Step 3: Set up an Index Page. ...
- Step 4: Copy the Config File for Each Site. ...
- Step 5: Edit the Config File for Each Site. ...
- Step 6: Enable Your Config File. ...
- Step 7: Verify Apache Configurations.
- Install the openldap, openldap-servers, and openldap-clients RPMs.
- Edit the /etc/openldap/slapd. ...
- Start slapd with the command: /sbin/service ldap start. ...
- Add entries to an LDAP directory with ldapadd.
- Use ldapsearch to determine if slapd is accessing the information correctly.
- # sudo apt-get update. # sudo apt install slapd ldap-utils.
- # sudo dpkg-reconfigure slapd.
- BASE dc=hadoop,dc=com. ...
- # cat hdp_cluster.ldif. ...
- # sudo auth-client-config -t nss -p lac_ldap. ...
- # /etc/init.d/nsd restart.
What port does Debian use for LDAP? ›
Enabling LDAPS on port 636
By default, slapd only supports StartTLS on the standard LDAP port 389. Some legacy LDAP clients do not support the StartTLS operation, but are able to use LDAPS (LDAP over SSL) on port 636.
- Download the installation media in the form of a ZIP file.
- Extract the contents of the Apache Web Server 2.4 zip to the file system.
- Locate the extracted Apache24 folder and copy this folder to the root of C:\
- Open the C:\Apache24\bin folder and run the httpd.exe command.
- Download the package. https://www.openoffice.org/download/other.html.
- Extract files. tar -xvzf Apache_OpenOffice_4.1.8_Linux_x86-64_install-deb_en-US.tar.gz.
- Installation. As root or sudo: ...
- Open Writer. Click the Writer option. ...
- Setup Apache OpenOffice. Enter the user first name, last name and initials.
- Restart Apache 2 web server, enter: # /etc/init.d/apache2 restart. $ sudo /etc/init.d/apache2 restart. ...
- To stop Apache 2 web server, enter: # /etc/init.d/apache2 stop. ...
- To start Apache 2 web server, enter: # /etc/init.d/apache2 start.
- su to root, if necessary, and navigate to Apache OpenOffice installation directory. ...
- cd into the RPMS subdirectory of the installation directory. ...
- Install this new version by typing rpm -Uvih *rpm . ...
- Install the desktop integration features for your setup. ...
- Finally, start up Apache OpenOffice 4.
Debian Installer, also known as “d-i”, is the software system to install a basic working Debian system. A wide range of hardware such as embedded devices, laptops, desktops and server machines is supported and a large set of free software for many purposes is offered.
How do I access Apache server on Linux? ›In Ubuntu and Debian-based distributions, the main configuration directory for the Apache server is /etc/apache2, while for CentOS, it's /etc/httpd. Hence, all the configuration files for the server are available inside these directories. Some of the most known files/directories are: /var/log/apache2/error.
How do I manually install httpd? ›...
Step 2:
- Navigate to directory /tmp/httpd-2.4. ...
- Run the command ./configure.
- If an error message is thrown requesting PCRE, jump to Step 3.
- Run the command make.
- Run the command make install.
- /etc/apache2/httpd. conf.
- /etc/apache2/apache2. conf.
- /etc/httpd/httpd. conf.
- /etc/httpd/conf/httpd. conf.