Adding virtual host on linux

1. domain added in linode panel

2. create virutal file

        ServerAdmin [email protected]
        DocumentRoot /home/your-domain/public_html/
        ErrorLog /home/your-domain/logs/error.log
        CustomLog /home/your-domain/logs/access.log combined

mkdir -p /home/your-domain/public_html
mkdir /home/your-domain/logs


to disable default site
a2dissite default

to enable default site
a2ensite default

to enable new virtual host site after creating virtual host file in /etc/apache2/sites-available/ run below command

to restart apache2
/etc/init.d/apache2 restart

reload new site without starting new site
/etc/init.d/apache2 reload

Creating self signed certificate to activate the ssl
su - root
mkdir /root/certs && cd /root/certs

Create the certificate:
openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out MyCertificate.crt -keyout MyKey.key

<VirtualHost *:443>
    SSLEngine On
    SSLCertificateFile /etc/ssl/certs/
    SSLCertificateKeyFile /etc/ssl/private/
    SSLCACertificateFile /etc/ssl/certs/ca-certificates.crt  #If using a self-signed certificate, omit this line

    ServerAdmin [email protected]
    ServerAlias #If using alternate names for a host
      DocumentRoot /var/www/html/
    ErrorLog /var/www/html/
    CustomLog /var/www/html/ combined

Ensure that the Apache SSL module is enabled, and enable the virtualhost configuration:

a2enmod ssl

service apache2 restart