virtual host debian apach2

i'm trying to add a new domain to my server which is running debian and apache2. How exactly should i go about adding the domain? Through the sites-enabled/available? and if so how do i do it

thanks


In Debian virtual hosts are enabled by default, so after you have configured your dns drop a file named as you like (e.g. site.example.org) in /etc/apache2/sites-available with this content

# This tell apache to enable this vhost for all ports
<VirtualHost *>
        # These two are the only mandatory params for a vhost
        ServerName your.dns.name # dns name for this vhost
        DocumentRoot /your/document/root # document root for this vhost

        # Optional, allow override in .htaccess files
        <Directory /your/document/root>
                Options FollowSymLinks
                AllowOverride All
        </Directory>

        # optional, log accesses and errors to a different file
        ErrorLog /var/log/apache2/your-name-error.log
        CustomLog /var/log/apache2/your-name-access.log combined
</VirtualHost>

Then as root run the command a2ensite site.example.org (the file name) and reload apache with /etc/init.d/apache2 reload as suggested by previous command. That's it.

If something goes wrong review your config with apache2ctl -t for syntax check and with apache2ctl -s for virtual host configuration.