Apache Virtual Hosts
June 19, 2024
In /etc/apache2/sites-available you will see something like that:
ls /etc/apache2/sites-available
000-default.conf 000-default-le-ssl.conf default-ssl.conf  
000-default.conf.dpkg-distUpload all your website files to /var/www/html/example.com
Then, copy the config file
cd /etc/apache2/sites-available  
sudo cp 000-default.com.conf example.com.confModify new conf file
<VirtualHost *:80>
    ServerAdmin your.email@gmail.com
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public_html
    <Directory /var/www/example.com/public_html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <IfModule mod_dir.c>
        DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
    </IfModule>
</VirtualHost>Enable the virtual host
sudo a2ensite example.com.confEnable SSL
sudo certbot --apache -d example.com -d www.example.comRestart apache
sudo systemctl restart apache2