On Debian-based systems, Apache uses the a2ensite and a2dissite commands to manage enabled sites through symlinks between sites-available and sites-enabled directories. However, RHEL/CentOS systems handle this differently:
# Typical Debian structure: /etc/apache2/ ├── sites-available/ └── sites-enabled/ # RHEL structure: /etc/httpd/ ├── conf/ └── conf.d/
To disable a site (like ssl.conf in your case), you have several options:
# Method 1: Rename the config file sudo mv /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf.disabled # Method 2: Change the extension sudo mv /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf.bak # Method 3: Comment out Include directive in main config # Edit /etc/httpd/conf/httpd.conf and change: # Include conf.d/*.conf # to: # Include conf.d/!ssl.conf
After making changes, you need to reload Apache:
# For RHEL 7/CentOS 7: sudo systemctl restart httpd # For RHEL 6/CentOS 6: sudo service httpd restart # For a graceful reload (without dropping connections): sudo systemctl reload httpd
If you prefer the Debian approach, you can implement it manually:
# Create directories
sudo mkdir -p /etc/httpd/{sites-available,sites-enabled}
# Add to httpd.conf
echo "IncludeOptional sites-enabled/*.conf" | sudo tee -a /etc/httpd/conf/httpd.conf
# Then create symlinks to enable sites
sudo ln -s /etc/httpd/sites-available/example.com.conf /etc/httpd/sites-enabled/
Always test your configuration before reloading:
sudo apachectl configtest # Sample output if successful: # Syntax OK
If you're coming from Debian/Ubuntu systems, you might be surprised that Red Hat Enterprise Linux (RHEL) and its derivatives (CentOS, Fedora) don't include the convenient a2ensite and dissite commands. These distributions handle Apache configuration differently.
On RHEL-based systems, Apache configurations are typically stored in:
/etc/httpd/conf/httpd.conf # Main configuration file /etc/httpd/conf.d/ # Additional configuration files
Unlike Debian's sites-available/sites-enabled structure, RHEL loads all .conf files from conf.d automatically. To disable a site, you need to either remove or rename its configuration file.
To achieve the equivalent of a2dissite ssl for ssl.conf:
# Rename the file (preferred method for easy restoration) sudo mv /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf.disabled # Alternatively, you could remove it (not recommended) # sudo rm /etc/httpd/conf.d/ssl.conf
After making changes, test your configuration and reload Apache:
sudo apachectl configtest sudo systemctl reload httpd
If you frequently need this functionality, you can create simple bash scripts:
#!/bin/bash
# a2dissite-rhel
if [ -z "$1" ]; then
echo "Usage: $0 <config>"
exit 1
fi
CONFIG_FILE="/etc/httpd/conf.d/${1}.conf"
if [ ! -f "$CONFIG_FILE" ]; then
echo "Error: $CONFIG_FILE not found"
exit 1
fi
sudo mv "$CONFIG_FILE" "${CONFIG_FILE}.disabled" && \
sudo systemctl reload httpd
For better management:
- Always keep backup copies of your configuration files
- Use descriptive file names (e.g.,
example.com.conf) - Consider version control for your configurations
- Document your changes in a changelog
After disabling SSL, verify it's not loaded:
sudo apachectl -S | grep ssl # Should return no output if successfully disabled