Setting Up Let’s Encrypt SSL on Apache or nginx on Linux
Securing your Apache or nginx servers with SSL certificates is crucial for protecting sensitive data and ensuring encrypted communication. Let’s Encrypt offers free, automated SSL certificates that can be easily installed on Linux servers. In this comprehensive guide, we will walk you through the process of setting up Let’s Encrypt SSL on Apache and nginx servers running on Linux.
Prerequisites
- A Linux server with Apache or nginx installed
- SSH access to the server
- A domain name pointed to your server’s IP address
Installing Let’s Encrypt Certbot
Before we can generate SSL certificates, we need to install Certbot, the official Let’s Encrypt client, on our server. Follow these steps:
- Update the package list:
sudo apt update
- Install Certbot for Apache:
sudo apt install certbot python3-certbot-apache
- Install Certbot for nginx:
sudo apt install certbot python3-certbot-nginx
Generating SSL Certificates
Once Certbot is installed, we can generate SSL certificates for our domain. Use the following commands based on your web server:
- For Apache:
sudo certbot --apache
- For nginx:
sudo certbot --nginx
Automating Certificate Renewal
Let’s Encrypt certificates expire every 90 days, so it’s important to set up automatic renewal. Add a cron job to run the renewal command periodically:
0 0 * * 0 certbot renew
Configuring SSL on Apache
To enable SSL on Apache, you need to edit the virtual host configuration file. Add the following lines within the appropriate <VirtualHost> block:
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/yourdomain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/yourdomain.com/privkey.pem
Configuring SSL on nginx
To configure SSL on nginx, modify the server block in the configuration file. Update it with the following lines:
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
Testing SSL Configuration
After configuring SSL, it’s essential to test the setup to ensure everything is working correctly. Use online SSL testing tools to check for any issues.
Troubleshooting Common Issues
If you encounter any problems during the setup process, here are some common troubleshooting tips:
- Check file permissions for SSL certificate files
- Verify that the domain is correctly pointed to the server
- Restart Apache or nginx after making configuration changes
Conclusion
By following this guide, you can successfully set up Let’s Encrypt SSL certificates on your Apache or nginx servers running on Linux. Protect your websites with encrypted connections and enhance security for your users.

DrayTek Vigor 2962 2.5Gb Ethernet Dual-WAN Broadband Firewall Router, 200 VPN Tunnels, 20 VLANS, QOS, Remote Management, Load Balancing
High Performance Multi-WAN Router - The Vigor 2962 makes full use of FTTP Fibre Broadband at up to 2.2Gbps throughput for single or multi-WAN configurations. With Quality of Service, Firewall and Content Filtering.
Buy Now on Amazon
NETGEAR Orbi Mesh WiFi 6 System (RBK763S) , Mesh Router & 2 Extenders , Cover Every Room, Up To 6,000 Sq Ft , Improve WiFi Speeds up to 5.4 Gbps & 75 devices , Simple App Set Up
WiFI mesh coverage of up to 6,000 sq ft and up to 75 devices, With each satellite (sold separately) you can extend the range by up to 2,000 sq ft
Buy Now on Amazon
DrayTek Vigor 2865Lax-5G Ethernet Router, WiFi 6 AX3000 Wireless and 5G Failover, Integrated 5G Modem, 5+1 GbE LAN Ports with VLANs, VDSL
VDSL and Ethernet Load Balancer - Connect the Vigor 2865 to Superfast Fibre with the integrated VDSL modem. Use the Ethernet WAN with Cable and Ultrafast FTTP. Load Balance multiple connections to boost performance.
Buy Now on Amazon
TP-Link Archer BE550 Router WiFi 7 BE9300Mbps, Tri-Band WiFi Router, 2.5G Ports,USB Port,Maximized Coverage,VPN Router, Parental Control, HomeShield Security, Private IoT Network,Easy Setup,EasyMesh
Wi-Fi 7 Routers: With powerful Wi-Fi 7 performance, lightning-fast wired connections, and brand-new design
Buy Now on Amazon
QNAP TS-253A-4G 2 Bay NAS Enclosure with 4GB RAM - Black (GDPR Compliant)
NAS and iSCSI-SAN unified storage solution for server virtualization
Buy Now on Amazon
WD 16TB My Cloud EX2 Ultra 2-bay NAS - Network Attached Storage RAID, file sync, streaming, media server, with WD Red drives
Centralised network storage: Organise your entire media collection, photos and files in one central, network location
Buy Now on Amazon
Synology DX517 5 Bay Desktop Network Attached Storage Expansion Enclosure, Black
Online volume expansion
Buy Now on Amazon
QNAP TS-431XeU-8G 4 Bay Short-depth Rackmount NAS Enclosure with 10GbE SFP+ & 8GB RAM
The short depth design is suitable for installing in smaller racks or space-constrained locations
Buy Now on Amazon
Seagate 10 TB IronWolf NAS 3.5 Inch Hard Drive ST10000VN0008 (SATA 6 Gb/s/256 MB/7200 RPM)
Model Number: ST10000VN0008
Buy Now on Amazon
QNAP TS-673A-8G 6 Bay Desktop NAS Enclosure - 8GB RAM, AMD Ryzen Quad-core 2.2 GHz Processor - with 2.5GbE connectivity & supporting PCIe expansion
8GB DDR4 RAM (2 x SODIMM slots, max. 64GB, optional ECC RAM support)
Buy Now on Amazon
Synology DS1621+ 48TB 6 Bay Desktop NAS Solution, installed with 6 x 8TB Western Digital Red Plus Drives
Accelerated Performance: 174% higher 4K random read IOPS and 76% faster sequential write speeds compared to its predecessor
Buy Now on Amazon
Synology DS1823xs+ 8 Bay NAS Desktop: High-Performance Storage Solution
Powerful Performance - Over 3,100/2,600 MB/s sequential read/write throughput and over 173,100/80,800 random read/write IOPS2 support heavier applications
Buy Now on Amazon