Braggers Tech Blog


Home > Linux Knowledge > How to setup a new site in Apache (Ubuntu)

published 2021-01-18, updated 2024-01-05

Here are the basic steps to create a new virtual host in Apache on Ubuntu Server. This includes HTTPS setup with LetsEncrypt certbot. apache2 and certbot (and dependencies) need to be installed first.

<VirtualHost *:80>
    ServerAdmin webmaster@sitename.tld
    ServerName  sitename.tld
    ServerAlias www.sitename.tld
    DocumentRoot /var/www/sitename.tld
    ErrorLog ${APACHE_LOG_DIR}/sitename.tld-error.log
    CustomLog ${APACHE_LOG_DIR}/sitename.tld-access.log combined
</VirtualHost> 

It is possible to add multiple sites to the same Apache server in the same manner. Just point your DNS A-Records to the correct server ip adress and Apache will do the rest.