Enter your details below and every command updates automatically. Toggle off anything you've already done — those steps will hide. Click step numbers to mark them complete as you go.
curl ifconfig.me
Run this from any machine:
dig +short example.com dig +short www.example.com
If both return your server's IP → DNS is set. If they return nothing or a different IP → you still need Step 1.
Run this on your server:
certbot --version
See a version number (e.g. "certbot 2.x.x") → it's installed. Get "command not found" → you need Step 2.
Check if directory listing is off and hidden files are blocked:
# See if security-hardening.conf (or similar) already exists: ls /etc/apache2/conf-enabled/ | grep -i secur # Check if ServerTokens is already set: grep -r "ServerTokens" /etc/apache2/ # Check if directory listing is disabled: grep -r "Options.*-Indexes" /etc/apache2/
If you see ServerTokens Prod and -Indexes in existing configs, hardening is likely already in place. You can toggle this off above or skip Step 5.
Check which firewall you use, then run the matching command:
# UFW (Ubuntu/Debian): sudo ufw status # firewalld (CentOS/RHEL): sudo firewall-cmd --list-all # iptables (manual): sudo iptables -L -n | grep -E '80|443'
Look for rules allowing ports 80 and 443. If you see them → they're open. Also check your cloud provider's Security Group if on AWS/GCP/Azure — those are separate from the OS firewall.
Run these to see if Certbot auto-renewal is already active:
# Check for a systemd timer: sudo systemctl list-timers | grep certbot # Or check for a cron job: sudo crontab -l | grep certbot cat /etc/cron.d/certbot 2>/dev/null
If you see a timer or cron entry mentioning certbot → renewal is already configured. If nothing comes back → you need the verification in the final step.
Log into your domain registrar (Namecheap, Cloudflare, GoDaddy, etc.) and create or update these two A records:
Type Host Value TTL A @ YOUR_SERVER_IP 300 A www YOUR_SERVER_IP 300
dig +short example.comsudo apt update sudo apt install certbot python3-certbot-apache -y
sudo dnf install epel-release -y sudo dnf install certbot python3-certbot-apache -y
First, create the document root directory:
sudo mkdir -p /var/www/example.com sudo chown -R www-data:www-data /var/www/example.com
Next, create the config file:
sudo nano /etc/apache2/sites-available/example.com.confCtrl + O → EnterCtrl + X<VirtualHost *:80> ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/example.com ErrorLog ${APACHE_LOG_DIR}/example.com-error.log CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined </VirtualHost>
Then enable the site:
sudo a2ensite example.com.conf sudo apache2ctl configtest
sudo ufw allow 'Apache Full' sudo ufw status
sudo nano /etc/apache2/conf-available/security-hardening.conf# BLOCK HIDDEN FILES & DIRECTORIES <DirectoryMatch "/\."> Require all denied </DirectoryMatch> # Allow .well-known for Certbot validation <Directory /var/www/example.com/.well-known> Require all granted </Directory> # BLOCK BACKUP & CONFIG FILES <FilesMatch "(\.(bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$"> Require all denied </FilesMatch> # DIRECTORY OPTIONS <Directory /var/www/example.com> Options -Indexes +FollowSymLinks AllowOverride None </Directory> ServerTokens Prod ServerSignature Off <IfModule mod_headers.c> Header always set X-Content-Type-Options "nosniff" Header always set X-Frame-Options "SAMEORIGIN" Header always set X-XSS-Protection "1; mode=block" Header always set Referrer-Policy "strict-origin-when-cross-origin" </IfModule>
Enable the config:
sudo a2enconf security-hardening sudo a2enmod headers rewrite ssl
sudo apache2ctl configtest sudo systemctl restart apache2
sudo certbot --apache -d example.com -d www.example.com
sudo systemctl restart apache2 sudo systemctl is-active apache2
Create a test page:
sudo nano /var/www/example.com/index.html
<!DOCTYPE html> <html> <head><title>HTTPS Test</title></head> <body> <h1>It works!</h1> <p>HTTPS is running on example.com</p> <p>Served at: <script>document.write(new Date())</script></p> </body> </html>
Test it:
curl -I https://example.com
sudo certbot renew --dry-run sudo systemctl list-timers | grep certbot