Use the below Snips for common installation and configuration of Apache Web Server
Make sure port 80 is open inbound from the Internet for Let's Encrypt to verify your name is pointing to the server.
apt install certbot python3-certbot-apache
certbot --apache --agree-tos --no-eff-email --redirect --hsts --uir --staple-ocsp --must-staple --email [email protected] -d example.com,www.example.com
Reference https://manpages.ubuntu.com/manpages/jammy/en/man1/certbot.1.html