Firstly create a new directory where the site will reside, normally:
/var/www/site-domain.com
Then change the ownership and permissions:
chown -R www-data:www-data site-domain.com
chmod -R 755 site-domain.com
Then duplicate the config file in /etc/apache2/sites-available
Typically a config file will look like this:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerName family-hub.online
ServerAlias www.family-hub.online
ServerAdmin [email protected]
DocumentRoot /var/www/family-hub.online/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/infinityloop.tech.error.log
CustomLog ${APACHE_LOG_DIR}/infinityloop.tech.access.log combined
<Directory "/var/www/family-hub.online">
Options FollowSymLinks
AllowOverride All
RewriteEngine On
</Directory>
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
RewriteCond %{SERVER_NAME} =family-hub.online [OR]
RewriteCond %{SERVER_NAME} =www.family-hub.online
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Then symlink the file from /etc/apache2/sites-available
to /etc/apache2/sites-enabled
like so:
ln -s /etc/apache2/sites-available/family-hub.online.conf /etc/apache2/sites-enabled/family-hub.online.conf
Or use Apache's own enabler:
a2ensite family-hub.online.conf
To disable a site:
a2dissite family-hub.online.conf