How to install a Let's Encrypt SSL certificate on Apache?
Install Certbot and its Apache plug-in; 2. Run Certbot to obtain the certificate and configure the domain name; 3. Optionally configure automatic redirection from HTTP to HTTPS; 4. Set up automatic renewal and pass dry-run test; 5. Verify the installation and ensure the normal reload configuration of Apache. After the certificate is successfully deployed, renewal will be automatically managed. After the entire process is completed, secure HTTPS access can be achieved.
Installing a Let's Encrypt SSL certificate on Apache is straightforward using Certbot, the official tool for managing Let's Encrypt certificates. Here's how to do it on a typical Linux server (eg, Ubuntu/Debian):

1. Install Certbot and the Apache Plugin
First, update your package list and install certbot
along with the Apache plugin:
sudo apt update sudo apt install certbot python3-certbot-apache
This plugin automatically configures Apache to use the SSL certificate.

2. Run Certbot to Get the Certificate
Run Certbot and follow the prompts:
sudo certbot --apache
Certbot will:

- Ask for your email (used for renewal reminders and security notices)
- Require agreement to the Let's Encrypt terms of service
- Prompt you to select domains (from your Apache virtual hosts)
Make sure your domain points to your server and that the Apache site is enabled.
3. Configure HTTPS Settings (Optional but Recommended)
During setup, Certbot may ask if you want to:
- Redirect HTTP traffic to HTTPS (choose 2 to enable redirect)
This ensures all traffic uses a secure connection.
4. Auto-Renewal Setup
Let's Encrypt certificates expire every 90 days. Certbot sets up a cron job or systemd timer automatically, but you can test renewal with:
sudo certbot renew --dry-run
If this runs without errors, renewal will work automatically.
5. Verify the Installation
Visit your site using https://yourdomain.com
. You should see a secure connection (padlock icon). You can also check using:
sudo apachectl configtest sudo systemctl reload apache2
Ensure Apache reloads properly after Certbot modifyes the config.
Troubleshooting Tips
- Make sure port 80 is open (required for domain validation)
- Your domain must resolve publicly
- If Apache fails to reload, check logs:
sudo tail -f /var/log/apache2/error.log
- Certificates are stored in
/etc/letsencrypt/live/yourdomain.com/
That's it. Certbot handles certificate generation, Apache configuration, and auto-renewal. Just keep your system updated and monitor logs occasionally.
The above is the detailed content of How to install a Let's Encrypt SSL certificate on Apache?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

ArtGPT
AI image generator for creative art from text prompts.

Stock Market GPT
AI powered investment research for smarter decisions

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

The core role of Homebrew in the construction of Mac environment is to simplify software installation and management. 1. Homebrew automatically handles dependencies and encapsulates complex compilation and installation processes into simple commands; 2. Provides a unified software package ecosystem to ensure the standardization of software installation location and configuration; 3. Integrates service management functions, and can easily start and stop services through brewservices; 4. Convenient software upgrade and maintenance, and improves system security and functionality.

First,verifythelibphp.sofileexistsusingfindorlocatecommands;ifmissing,reinstallPHPwithApachesupportviapackagemanager.2.CheckApacheconfigurationfilesforcorrectLoadModuledirectivepathandremoveduplicates.3.EnsureApacheandPHPversionsandarchitecturesmatch

KeepAliveOn enables persistent connections; 2.MaxKeepAliveRequests100 sets the maximum number of requests per connection; 3.KeepAliveTimeout5 sets the timeout for waiting for subsequent requests, restart Apache after configuration and use curl or browser developer tools to verify whether KeepAlive is effective to optimize server performance.

Install Certbot and its Apache plug-in; 2. Run Certbot to obtain the certificate and configure the domain name; 3. Optionally configure automatic redirection from HTTP to HTTPS; 4. Set up automatic renewal and pass dry-run test; 5. Verify the installation and ensure the normal reload configuration of Apache. After the certificate is successfully deployed, renewal will be automatically managed. After the entire process is completed, secure HTTPS access can be achieved.

ThebestApacheMPMdependsonyourapplicationstackandtrafficneeds:1.UsePreforkifrelyingonnon-thread-safemoduleslikemod_phpandprioritizingstability.2.UseWorkerformoderatetohightrafficwiththread-safesetupsandbettermemoryefficiency.3.UseEventforhighconcurren

OnDebian/Ubuntu,themainApacheconfigurationfileis/etc/apache2/apache2.conf,withadditionalconfigurationsin/etc/apache2/sites-available/and/etc/apache2/conf-available/.2.OnRHEL/CentOS/Fedora,itistypically/etc/httpd/conf/httpd.conf,withextrafilesin/etc/h

ThedefaultApacheportforHTTPis80.1.Port80isusedforunencryptedHTTPtrafficandisthestandardforwebserversincludingApache.2.WhenaURLisenteredwithoutaspecifiedport,browsersautomaticallyconnecttoport80.3.ForHTTPStraffic,thedefaultportis443,commonlyconfigured

To set up a custom 404 error page, you need to create a page file and configure the path in Apache. 1. Create a custom 404 page, such as saving 404.html to the website root directory; 2. Add ErrorDocument404/404.html to the .htaccess file of the website root directory to ensure that AllowOverride is enabled; 3. If you use VPS or a standalone server, you can add ErrorDocument404/404.html in the virtual host configuration file (such as 000-default.conf) and restart the Apache service; 4. Test whether the custom page takes effect by accessing the non-existent URL. When configuring
