Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

Best practices to secure your Apache Web Server

Server Version Banner should be removed.

I’d say this is one of the first things to think about, because you don’t want to reveal your web server version. By exposing the version, you are assisting the hacker in expediting the reconnaissance process.

The Apache Version and OS Type will be exposed by default, as illustrated below.

  • Go to the $Web Server/conf directory.
  • Using the vi editor, modify httpd.conf.
  • Save the httpd.conf file after adding the following directive.
ServerTokens "Prod"
ServerSignature "Off"Code language: JavaScript (javascript)
  • Apache should be restarted

The version information in the page generated by Apache will be removed by ServerSignature.

Header will be changed to production only by ServerTokens, i.e., Apache.

As you can see in the screenshot below, the version and operating system information has vanished.

Disable the directory browser’s display.

Disable directory listing in a browser to prevent visitors from seeing all of the files and folders under the root or subdirectory.

Let’s see how it looks with the default settings.

  • Go to the $Web Server/htdocs directory.
  • Make a folder with a few files inside it.
# mkdir test
# cd test
# touch hi
# touch helloCode language: PHP (php)

Now, go to http://localhost/test and try to connect to Apache.

As you can see, it shows all of your files and directories, which I am sure you don’t want to expose that.
  • Go to the $Web Server/conf directory.
  • Using vi, open httpd.conf.
  • Change the Options directive to None or –Indexes after you’ve added the Directory.
<Directory /opt/lampp/htdocs/test>
Options -Indexes
</Directory>Code language: HTML, XML (xml)

or

<Directory /opt/lampp/htdocs/test>
Options None
</Directory>Code language: HTML, XML (xml)

Note: If your environment contains multiple Directory directives, you should consider implementing the same thing for all of them.

  • Restart Apache
  • Now, go to http://localhost/test and try to connect to Apache.

Instead of displaying the test folder listing, it displays a forbidden error.

Use a non-privileged account to run Apache.

Nobody or daemon is the default user account for a default installation. It’s a good idea to provide Apache its own non-privileged user.

The goal is to protect other services running in case of any security hole.

  • Create an apache user and group.
# groupadd apache
# useradd –G apache apacheCode language: PHP (php)
  • Change the ownership of the apache installation directory to a newly created non-privileged user.
# chown –R apache:apache /opt/lamppCode language: PHP (php)
  • Go to the $Web Server/conf directory.
  • Using vi, open httpd.conf
  • Change the User & Group Directive to non-privileged account apache by searching for it.
User apache 
Group apache
  • Save the httpd.conf configuration file.
  • Restart Apache
  • grep for running http processes and make sure they’re all running with the apache user.
# ps –ef |grep httpCode language: PHP (php)
  • One process should be running as root, as you can see. This is due to the fact that Apache listens on port 80 and must be run as root.

Permissions on binary and configuration directories should be protected.

The binary and configuration permissions are set to 755 by default, which implies that any user on the server may see the settings. You can deny access to the conf and bin folders to another user.

  • Go to the $Web Server/conf directory.
  • Bin and conf folder permissions should be changed.
chmod –R 750 bin conf





Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at <a href="https://www.cotocus.com/">Cotocus</a>. I share tech blog at <a href="https://www.devopsschool.com/">DevOps School</a>, travel stories at <a href="https://www.holidaylandmark.com/">Holiday Landmark</a>, stock market tips at <a href="https://www.stocksmantra.in/">Stocks Mantra</a>, health and fitness guidance at <a href="https://www.mymedicplus.com/">My Medic Plus</a>, product reviews at <a href="https://www.truereviewnow.com/">TrueReviewNow</a> , and SEO strategies at <a href="https://www.wizbrand.com/">Wizbrand.</a> Do you want to learn <a href="https://www.quantumuting.com/">Quantum Computing</a>? <strong>Please find my social handles as below;</strong> <a href="https://www.rajeshkumar.xyz/">Rajesh Kumar Personal Website</a> <a href="https://www.youtube.com/TheDevOpsSchool">Rajesh Kumar at YOUTUBE</a> <a href="https://www.instagram.com/rajeshkumarin">Rajesh Kumar at INSTAGRAM</a> <a href="https://x.com/RajeshKumarIn">Rajesh Kumar at X</a> <a href="https://www.facebook.com/RajeshKumarLog">Rajesh Kumar at FACEBOOK</a> <a href="https://www.linkedin.com/in/rajeshkumarin/">Rajesh Kumar at LINKEDIN</a> <a href="https://www.wizbrand.com/rajeshkumar">Rajesh Kumar at WIZBRAND</a> <a href="https://www.rajeshkumar.xyz/dailylogs">Rajesh Kumar DailyLogs</a>

Related Posts

Java Installation Guide in Linux & Windows

DOWNLOAD OPEN JDK & JRE JAVA PACKAGE FROM – https://jdk.java.net/archive/ Download and Install JDK/JRE 7 in Centos & RHEL Download and Install JDK/JRE 8 in Centos &…

Read More

Linux Tutorials: Commands for Linux Administrator

1. sudo – Execute commands with elevated privileges, a fundamental for system administration. 2. useradd – Create a new user account, essential for managing user access. 3….

Read More

Linux Tutorials: How to troubleshoot Linux Server?

If a linux-build-server suddenly starts getting slow, I would divide my approach / troubleshooting into 3 section as follows; System Level troubleshooting Application Level troubleshooting Dependent Services troubleshooting…

Read More

What is Linux and use cases of Linux?

What is Linux? Linux is an open-source, Unix-like operating system kernel first created by Linus Torvalds in 1991. It serves as the foundation for a wide range…

Read More

Jenkins Tutorial: Install Jenkins on Ubuntu

In this tutorial we are going to install Jenkins on Ubuntu operating system. Ubuntu is another debian based operating system – open sourced and highly loved by…

Read More

Linux Performance Monitoring Guide

CPU Memory Network Storage Device and Input I/O Storage Capacity Storage Controller CPU Memory and I/O Interconnect Rajesh Kumar I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge…

Read More