Skip to main content

How to Installing an SSL certificate in Apache2 and cPanel ?

 

Installing an SSL certificate in Apache2 and cPanel involves two main steps:

1. Generate or obtain an SSL certificate:

There are two ways to acquire an SSL certificate:

  • Generate a self-signed certificate: This is useful for testing purposes but not recommended for production environments as it raises security warnings in browsers. You can generate one using the OpenSSL command-line tool or through cPanel's "Generate, view, upload, or delete SSL certificates" section.

         Purchase an SSL certificate from a Certificate Authority (CA): This is the recommended approach for production websites. Popular CAs include DigiCert, Comodo, Let's Encrypt (free option), etc. Choose a certificate that meets your security and domain validation needs.



2. Install the SSL certificate in Apache2:

Here are the two main methods for installing the certificate:

Method 1: Using cPanel's SSL/TLS Manager:

  1. Login to your cPanel account.
  2. Navigate to the "SSL/TLS" section.
  3. Click on "Manage SSL Sites".
  4. Select your domain name from the list.
  5. Choose "Autofill by Domain" or "Autofill by Certificate" depending on how you obtained the certificate files.
  6. If using "Autofill by Certificate", enter the paths to your certificate, key, and intermediate certificate files (if applicable).
  7. Click "Install Certificate".

Method 2: Manual installation:

  1. Obtain the certificate files (certificate.crt, key.pem, and intermediate certificates if any).
  2. Edit the appropriate Apache virtual host configuration file (usually located in /etc/apache2/sites-available/ or /etc/httpd/conf.d/).
  3. Add the following directives to the virtual host configuration, replacing the placeholders with your actual file paths:
SSLEngine on
SSLCertificateFile /path/to/certificate.crt
SSLCertificateKeyFile /path/to/key.pem
SSLCACertificateFile /path/to/intermediate_certificate.crt (if applicable)
  1. Save the changes to the virtual host file.
  2. Restart the Apache web server using the command sudo systemctl restart apache2 (or equivalent for your system).

Important notes:

  • Ensure you have proper ownership and permissions for the certificate files.
  • Replace the placeholders in the provided commands with your actual file paths and domain names.
  • If using Let's Encrypt, you'll need to follow their specific instructions for obtaining and renewing the certificate.
  • For specific details and troubleshooting, refer to your web hosting provider's documentation or the official Apache documentation.

Remember, installing an SSL certificate is a critical step for securing your website and protecting user data. Choose the method that best suits your technical expertise and resources.

Comments

Popular posts from this blog

How to Add an XML Sitemap to your Blogger Blog?

  Adding an XML sitemap to your Blogger blog can help search engines like Google discover your content more efficiently. Here are two ways to do it: Method 1: Using Blogger's Built-in Sitemap Functionality: Log in to your Blogger dashboard. Click on "Settings" in the left-hand menu. Go to the "Search Preferences" tab. Under "Crawling and Indexing," enable the "Custom robots.txt" option. Copy and paste the following code into the robots.txt field: Sitemap: https://yourblogname.blogspot.com/sitemap.xml Replace yourblogname with your actual blog's name. Click "Save Changes." Blogger automatically generates and updates the sitemap at https://yourblogname.blogspot.com/sitemap.xml . You can now submit this URL to search engines like Google Search Console for faster indexing.   Method 2: Using a Sitemap Generator: Visit a website like Labnol's Blogger Sitemap Generator: [<invalid URL removed>]. Enter ...

Top 10 shortcut keys for visual studio code

  Visual Studio Code is a popular code editor known for its customization and extensive keyboard shortcuts. Here are 10 of the most useful shortcut keys to help you boost your productivity: Command Palette (Ctrl+Shift+P or Cmd+Shift+P): This is your gateway to all of VS Code's features and settings. Type in what you want to do, and VS Code will show you a list of matching commands. Opens in a new window code.visualstudio.com Command Palette in Visual Studio Code Quick Open (Ctrl+P or Cmd+P): Quickly open a file or symbol in your project by name. Opens in a new window marketplace.visualstudio.com Quick Open in Visual Studio Code Toggle Sidebar (Ctrl+B or Cmd+B): Hide or show the sidebar, which contains the Explorer, Search, SCM, and other panels. Opens in a new window gosamples.dev Toggle Sidebar in Visual Studio Code Multi-Select Cursor (Alt+Click or Option+Click): Add multiple cursors at different locations in your code to edit or delete them simultaneously. Opens in...

GET request to the above URL and return the result we would use:

// Get cURL resource $curl = curl_init(); // Set some options - we are passing in a useragent too here curl_setopt_array( $curl , array ( CURLOPT_RETURNTRANSFER => 1 , CURLOPT_URL => 'http://url.com/?item1=value&item2=value2' , CURLOPT_USERAGENT => )); // Send the request & save response to $resp $resp = curl_exec( $curl ); // Close request to clear up some resources curl_close( $curl );