If you’re setting up a web server with AlmaLinux in 2025, chances are Apache is your go-to. It’s stable, open-source, and still one of the most trusted names in the hosting world. But once it’s installed, configuring it properly—especially adjusting document roots and virtual hosts—can make all the difference between a clunky setup and a smooth operation. This guide walks you through configuring Apache server paths on AlmaLinux from start to finish, in a clean, step-by-step format that works whether you’re new to server management or brushing up your skills.
Why Apache + AlmaLinux Is a Smart Combo
AlmaLinux has become the preferred CentOS alternative. It’s free, community-driven, and Red Hat compatible—making it a reliable OS choice for modern web hosting. Pair that with Apache (httpd), and you get a flexible, secure, and scalable environment for websites or applications.
Step 1: Install Apache on AlmaLinux
First things first: let’s get Apache installed.
bash
sudo dnf install httpd -y
Once done, enable it to start at boot and fire it up:
bash
sudo systemctl enable httpd
sudo systemctl start httpd
To make sure it’s running:
bash
sudo systemctl status httpd
You should see something like “active (running).” Great, you’re ready for configuration.
Step 2: Know Where Apache Lives (Key Paths)
Here’s a quick roadmap to the Apache file structure on AlmaLinux:
- /etc/httpd/ – Main Apache config directory
- /etc/httpd/conf/httpd.conf – Primary configuration file
- /etc/httpd/conf.d/ – Folder for adding custom site configs
- /var/www/html/ – Default web root (your website files go here)
Step 3: Change the Default Document Root
Let’s say you don’t want to use /var/www/html/. Maybe you’re hosting a client or organizing multiple sites. Here’s how to point Apache to a new folder.
Create Your New Web Directory
bash
sudo mkdir -p /var/www/myproject
Set Proper Permissions
bash
sudo chown -R apache:apache /var/www/myproject
sudo chmod -R 755 /var/www/myproject
Edit or Create a Virtual Host File
Instead of changing the default config, it’s cleaner to add a new one:
bash
sudo nano /etc/httpd/conf.d/myproject.conf
Paste this:
apache
<VirtualHost *:80>
ServerAdmin webmaster@myproject.com
DocumentRoot /var/www/myproject
ServerName myproject.com
ErrorLog /var/log/httpd/myproject-error.log
CustomLog /var/log/httpd/myproject-access.log combined
</VirtualHost>
Restart Apache to Apply Changes
bash
sudo systemctl restart httpd
Now Apache will serve your site from the new path /var/www/myproject
.
Step 4: Configure Firewall (if needed)
If you’re using firewalld, allow HTTP and HTTPS traffic:
bas
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
This ensures your site is publicly accessible.
Step 5: Verify Apache Configuration
Before going live, always test your Apache syntax:
bash
sudo apachectl configtest
If you see “Syntax OK,” you’re good to go.
Step 6: Hosting Multiple Sites with Virtual Hosts
Hosting more than one site? Just repeat the virtual host setup from earlier with new DocumentRoot
paths and domain names. Apache lets you manage them all from one server like a pro.
Bonus Tips: Apache Security Essentials
- Disable directory listing by adding
Options -Indexes
in your VirtualHost block - Use mod_security and mod_evasive for basic attack protection
- Keep Apache updated to avoid exploits
- Add SSL (Let’s Encrypt is free!) using Certbot for HTTPS
Final Thoughts
It is clear that Apache and AlmaLinux combines these tools to provide a controlled sophisticated environment for developers, agencies, and businesses. By adjusting the steps of the path configuration on your apache servers, you enhance your base of operations to be faster, more secure, and scalable.
From personal projects to massive client websites, implementing best practices like these means the server can be reliable and grow seamlessly with you.
Frequently Asked Questions
1. Can I change the Apache default directory without virtual hosts?
Yes, but it’s not recommended. Using virtual hosts keeps things organized and scalable as your server grows.
2. What’s the best way to secure Apache on AlmaLinux?
Keep the server updated, disable unused modules, enable firewalls, and use SSL. Start simple and build up your security posture as needed.
3. How can I set up multiple domains on one server?
Just create separate virtual host files in /etc/httpd/conf.d/, each with its own domain, DocumentRoot, and log paths.
4. Does Apache support PHP and other scripting languages?
Absolutely. You can easily install PHP, Python, or Perl modules alongside Apache using DNF.
5. Is AlmaLinux stable for production web hosting?
Yes! AlmaLinux is a 1:1 binary-compatible fork of RHEL (Red Hat), making it a stable, secure, and long-term supported OS perfect for production servers.
6. What are the default Apache server paths on AlmaLinux and can I change them?
By default, the Apache server paths on AlmaLinux include /etc/httpd/ for configuration files and /var/www/html/ as the web root directory. You absolutely can change these paths to better organize your projects or host multiple websites. Simply modify the DocumentRoot
in your virtual host configuration, typically found in /etc/httpd/conf.d/, and restart Apache to apply the changes.