Skip to content

Instantly share code, notes, and snippets.

@Bhavya8181
Forked from jack2jm/SSL Domain Using Certbot
Created February 12, 2024 05:52
Show Gist options
  • Select an option

  • Save Bhavya8181/c146b3f3aeddb4266b16e72fdc0512a3 to your computer and use it in GitHub Desktop.

Select an option

Save Bhavya8181/c146b3f3aeddb4266b16e72fdc0512a3 to your computer and use it in GitHub Desktop.
********** Add A Record ***********
1.An A record with @ pointing to your server’s public IP address.
2. An A record with www pointing to your server’s public IP address.
************* check if apache installed or not *****
sudo apache2ctl configtest -> it will return not found commmand
install
sudo apt update
sudo apt install apache2
sudo ufw app list //check firewall list
******************* Installing Certbot ******************
First, add the repository:
Command: sudo add-apt-repository ppa:certbot/certbot
Install Certbot’s Apache package with apt:
sudo apt install certbot python3-certbot-apache
Command: sudo apt install python-certbot-apache
****************** Check System status ****************888
sudo apache2ctl configtest
******** Check apache 443 port is listening or not *****
netstat -ltn (check 443 port is listen or not)
***** Enable SSL Module - if netstat command not listening 443 *******
sudo a2enmod ssl
***************** UFW status ****************
sudo ufw status
-------------------- Create Config file for Domain Name ----------------------
1. sudo nano your_domain.com.conf // create new file
past your virtual host file data.
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/yourdomain_directory
ServerAlias www.yourdoamin.com
ServerName yourdoamin.com
<Directory /var/www/html/yourdomain_directory>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
2. Ctrl + O & enter. to save data
--------------------------------------------------
3. Add your new config file to apache
sudo a2ensite your_domain.com.conf
4.----- REstart apache -----
sudo apache2ctl configtest ///syntax check
sudo service apache2 restart
5. install certificate
sudo certbot --apache -d your_domain -d www.your_domain
6. Give option 2 > http to https redirect.
7. Check Existing certbot
sudo certbot certificates
8. Renew Certificate
sudo certbot renew --cert-name find_certificate_name_from_above_command
9. Delete Existing CErtificate -----
sudo certbot delete --cert-name find_certificate_name_from_above_command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment