Slackware HowTo

Configure multiple Apache VirtualHosts on Slackware

Serve multiple sites from the same Apache instance with distinct host headers and readable config.

1. When to use it

Handy for internal environments, staging, and separated services that you want to keep on the same httpd instance.

apache | virtualhost | ServerName | documentroot | configtest

2. Base setup

cat >> /etc/httpd/httpd.conf <<'EOF'
NameVirtualHost *:80
<VirtualHost *:80>
  ServerName app1.example.lan
  DocumentRoot /srv/httpd/app1
</VirtualHost>
EOF
apachectl configtest
/etc/rc.d/rc.httpd restart

Adjust host names, IPs, interfaces, paths, and versions to the real system before making the change persistent.

3. Quick verification

httpd -S
curl -H 'Host: app1.example.lan' http://127.0.0.1/
grep -n 'ServerName app1.example.lan' /etc/httpd/httpd.conf

Confirm that the output matches the expected state before considering the intervention complete.

4. Operational notes

Separate content and logs per VirtualHost: when sites grow, configuration readability matters as much as the service itself.

Quick checklist

[ ] Steps completed\n[ ] Config updated\n[ ] Tests executed\n[ ] Rollback ready\n[ ] Logs checked

Back to Linux HowTo