How to Install and Customize Apache on Ubuntu or Debian?
Last Updated :
21 Jun, 2024
One of the most dominant forces in web server software is the Apache HTTP Server, often shortened to Apache. This free and open-source project, overseen by the Apache Software Foundation, has been a major player in shaping the Internet since its launch in 1995. Installing an Apache web server on Ubuntu or Debian is a straightforward process, but the specific commands might differ slightly depending on your Linux distribution. In this article, we will install Apache Web Server on various Linux distributions like Ubuntu, Debian, etc.
Steps to Install Apache Web Server in Linux (Debian)
Step 1: Check your Linux distribution.
- Use the following command to check which Linux distribution you are using.
grep -E '^(VERSION|NAME)=' /etc/os-release
Checking linux distribution (Linux Mint Debian OS)Step 2: Update Your System.
sudo apt update && sudo apt upgrade
Step 3: Install Apache Web Server
sudo apt install apache2 -y
Step 4: Enable the Services
sudo systemctl enable apache2
Step 5: Test the Server by Hosting Simple Website
- First, we will create a directory for our test website using following command.
sudo mkdir /var/www/html/test_website
- Now we will add index.html for our test website along with some testing code using following command
echo ' <html>
<head>
<title>Example</title>
</head>
<body>
<h1 style="color:green">GFG</h1>
<p>This is a Apache Test Server for Ubuntu and Debian</p>
</body>
</html>' | sudo tee /var/www/html/test_website/index.html
- Now we will add configuration file using following command
sudo echo '<VirtualHost *:80>
ServerName web.testingserver.com
DocumentRoot /var/www/html/website
DirectoryIndex index.html
ErrorLog /var/log/httpd/example.com_error.log
CustomLog /var/log/httpd/example.com_requests.log combined
</VirtualHost>' >
/etc/httpd/conf.d/web.conf
- Once we created the required config file and test website, we will need to own the Apache website directory for permissions.
- We will use chown and chmod command as follows
sudo chown -R apache: apache /var/www/html/test_website
sudo chmod -R 755 /var/www/html/test_website
- Now you can see locally hosted website on localhost.
Link: http://localhost
testing website on local server
Similar Reads
How To Install apache2-dev on Ubuntu The Apache HTTP Server Project's purpose is to provide a standards-compliant open-source HTTP server that is secure, efficient, and extensible. As a result, it has long been the most used web server on the Internet. This package contains development headers and the apxs2 binary for the Apache 2 HTTP
3 min read
How to Install an SSL Certificate on Apache that run Ubuntu? This guide explains installing an SSL certificate on an Apache 2 server. It covers steps such as downloading and uploading the certificate file, configuring the necessary parameters on the Apache 2 server, and verifying the installation. Key parameters include the certificate file, certificate chain
4 min read
How to install and set up Apache Virtual Hosts on Ubuntu? Every website that is published on the Internet is housed on a web server (host), which is able to handle requests for web pages made by clients using browsers like Chrome, Firefox, or Internet Explorer and is connected to the network with a public IP address. Install a web server before hosting a w
4 min read
How To Install the Apache Web Server on Debian 11? Apache is an open-source web server thatâs available for Linux servers free of charge. Installing an Apache web server on Linux is a straightforward process. In this article, we will install Apache Web Server Debian 11 (Bullseye). Steps to Install Apache Web Server in LinuxStep 1: Update Your System
3 min read
How to Install Apache with PHP-FPM on Ubuntu? The Apache HTTP Server is a free, open-source, cross-platform web server software. It is developed and maintained by Apache Software Foundation. Apache is the most widely used web server around the world. The vast majority of Apache HTTP server instances run on Linux distribution, but current versio
4 min read