СHRISTMAS
WHEEL OF FORTUNE

Tap the button and win a guaranteed prize right now!

By registering, you are signing up to receiving e-mails.
JT
October 12 2023
Updated October 12 2023

How to configure Apache?

Debian Web server

Introduction

At the beginning of 21-st century you may have heard about new revolution in information technologies WEB 2.0 and now we almost go to the WEB 3.0, but let's talk about the tiny detail. What that's mean?  WEB or World Wide Web it's technology or global system unify web, DNS and CDN server's, which represent service for searching, using the content: web-pages, web-application and web-services. That system divide on timeline by version 1.0, 2.0 and coming 3.0. But one of the main detail in that schema—webserver. It represent software process queries from clients and form answers due to the configuration and rules on it.

Configuration

We already have installed Apache2 packet in our machine, for starting the web-server we need to check service in the sysetmd, start it and enable autostart:

systemctl list-units | grep "apache2"

On the display will pop-up list of units with filtering option apache2, save label of unit and start them by the command below:

systemctl start apache2.service

Then enable autostart at the boot:

systemctl enable apache2.service

Make sure that web-server have permission to change configuration by the additional files, for that we can change value AllowOverride to All:

nano /etc/apache2/apache2.conf
Main config
Screenshot №1 — Main config

In the different versions of Apache2, represent two examples of main config: httpd.conf and apache2.conf. For determine file in your case, use command below:

find / -name httpd.conf && find / -name apache2.conf
Search
Screenshot №2 — Search

Enabling AllowOverride empowers the server to understand directives defined within .htaccess files found in your website's folders. This capability fosters greater flexibility and customization possibilities on a per-directory basis, thereby elevating both the functionality and security of your web server.

We can now proceed to configure the .htaccess file, which serves as an extension to our existing configuration. Any alterations and settings within this file will influence the configuration outcome. Let's illustrate how this works with a standard configuration.

At the first, we should to activate function which help us override currently settings for the each of sites by the command below:

mkdir /etc/site-test
nano /etc/apache2/sites-available/000-default.conf
Config of site
Screenshot №3 — Config of site

Modify the ServerName parameter to reflect your own domain and set AllowOverride to the value All. It's important to note that you should have a corresponding DNS record on your provider panel there is record with the public IP address of needed server. Additionally, adjust the "DocumentRoot" which containing the html and another files for your desired website. We're creating a directory named site-test. and main page index.html:

nano /etc/site-test/index.html
Web-page
Screenshot №4 — Web-page
<! DOCTYPE html>
<html>
<head>
<title>OUR SITE</title>
</head>
<body>
<h1>ALL WORKING PROPERLY!</h1>
</body>
</html>

The content and structure of your web-page can be different, but the main part should be untouchable. Now, in the same directory, let's generate a new file that establishes a logic of behaviour. Let's create the file:

nano /etc/site-test/.htaccess
RewriteEngine On
RewriteRule ^hello$ index.html [L]
Site config
Screenshot №5 — Site config

On the screen above we turn up rewrite module which we install in the next step. In the follow line, we establish a rule linked to an page and associate to it attribute [L], indicating that it's the final step to run, with any subsequent instructions being ignored. To ensure proper functionality, it's crucial to enable the rewrite module, which is bundled within the Apache2 package, and therefore restart the service.

sudo a2enmod rewrite && systemctl restart apache2
Enable module
Screenshot №6 — Enable module

Make sure, that our changes have applied:

Result
Screenshot №7 — Result

Conclusion

In a nutshell, consider the main point's in the configuration of web-server .That allow to control account and access, provide hardening system, gracefully manage errors, and elegantly redirect URLs. That also provide set of settings to create your first web-page, ensuring a truly unique and dynamic online experience.

Vote:
5 out of 5
Аverage rating : 5
Rated by: 2
33145 North Miami, FL 2520 Coral Way apt 2-135
+1 302 425-97-76
700 300
ITGLOBAL.COM CORP
700 300

You might also like...

We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.