All Products
Search
Document Center

Certificate Management Service:Install an SSL/TLS certificate on an Apache server (Windows)

Last Updated:May 22, 2026

Deploy an SSL/TLS certificate on your Windows Apache server to enable HTTPS encryption. This guide covers certificate preparation, Apache configuration, and deployment verification.

Requirements

Before you begin, make sure that the following requirements are met:

  • Certificate Status: You have an SSL certificate issued by a trusted certificate authority (CA). If your certificate is expiring or has expired, you must renew it first.

  • Domain Name Matching: Ensure the certificate covers all domain names you want to protect. If you need to add or change a domain name, you can purchase a paid certificate or add and replace domain names.

    • Exact domain name: An exact domain name certificate applies only to the specified domain name.

      • A certificate for example.com applies only to example.com.

      • A certificate for www.example.com applies only to www.example.com.

    • Wildcard domain name: A wildcard domain name certificate applies only to first-level subdomains.

      • A certificate for *.example.com applies to first-level subdomains such as www.example.com and a.example.com.

      • A certificate for *.example.com does not apply to the root domain example.com or multi-level subdomains such as a.b.example.com.

    Note

    To match a multi-level subdomain, the Bound Domains field must include the specific domain name (for example, a.b.example.com) or a corresponding wildcard domain name (for example, *.b.example.com).

  • Server permissions: You must use the Administrator account or an account with administrator privileges.

  • DNS Resolution: The domain name resolves to the server's public IP address.

  • Environment dependencies: This tutorial uses Windows Server 2025 and Apache 2.x as examples. The sample Apache installation directory is C:\Apache24.

    Note

    Steps may vary depending on your OS or Apache version.

Procedure

Step 1: Prepare the certificate

  1. Go to the SSL Certificate Service page. In the Actions column for your certificate, click More to open the certificate details page. On the Download tab, download the certificate for the Apache Server Type.

  2. Extract the downloaded certificate package.

    • If the package contains a certificate file (<your_domain_name>_public.crt), a certificate chain file (<your_domain_name>_chain.crt), and a private key file (<your_domain_name>.key), store all three files securely for deployment.

    • If the package contains only a certificate file (<your_domain_name>_public.crt) and a certificate chain file (<your_domain_name>_chain.crt) without a private key file (<your_domain_name>.key), use the private key file you saved locally.

      Note

      If you generated the CSR with OpenSSL or Keytool, the private key exists only on your local machine. If lost, the certificate becomes unusable and you must purchase a new commercial certificate with a new CSR and private key.

  3. Upload the certificate, chain, and private key files to a directory outside the web root. This guide uses D:\cert.

    Note

    The following steps use an Alibaba Cloud ECS instance as an example. For other server types, refer to your server's documentation.

    1. Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.

    2. On the instance details page, click Connect and select Workbench. Log on to the server desktop.

    3. Click the Start menu and open This PC, Computer, or File Explorer.

    4. Under Redirected drives and folders, double-click workbench on ***. Drag the certificate files to this directory, then right-click and select Refresh.

      image

    5. Copy the files to the D:\cert directory.

      Important

      Workbench clears all uploaded files from Redirected drives and folders on reconnect or sign-out. Use this directory for transfer only — do not store files here permanently.

Step 2: Configure system and network settings

  1. Open port 443 in the security group.

    Important

    If your server is deployed on a cloud platform, make sure that its security group allows inbound traffic on TCP port 443. Otherwise, the service is not accessible from the internet. The following operations use an Alibaba Cloud ECS instance as an example. For other cloud platforms, see their official documentation.

    1. Go to the ECS Instances page, select the region where your target ECS instance is located, and click the instance name to go to the details page.

    2. Click Security Groups > Inbound Rules and make sure a rule exists with Action set to Allow, Protocol Type set to TCP, Port Range set to HTTPS(443), and Authorization Object set to Anywhere (0.0.0.0/0).

    3. If such a rule does not exist, add one to the target security group. For more information, see Add a security group rule.

  2. Open port 443 in the server firewall.

    1. Log on to your Windows server, click the Start menu, and then open Control Panel.

    2. Go to System and Security > Windows Defender Firewall > Check firewall status.

    3. If the firewall is turned off as shown in the following figure, no further action is required.image

    4. If the firewall is turned on, follow these steps to allow HTTPS traffic.

      1. In the left-side navigation pane, click Advanced settings > Inbound Rules and check whether an inbound rule exists for which Protocol is TCP, Local Port is 443, and Action is Block.

      2. If such a rule exists, right-click the rule, select Properties, and on the General tab, change the action to Allow the connection. Then, click Apply.

Step 3: Deploy the certificate

Open Command Prompt (cmd.exe) as an administrator:

  1. Navigate to the Apache installation directory and check the version.

    # In the command line, go to the Apache installation directory and use a relative path to run the command.
    .\httpd.exe -v
  2. Modify the configuration file based on your Apache version.

    Apache 2.4.8 and later

    1. Combine the certificate files.

      If you have an intermediate certificate, append the server certificate (your_domain_name_public.crt) and chain file (your_domain_name_chain.crt) into a combined file (your_domain_name_fullchain.pem).

      # Append the content of the intermediate certificate file to the server certificate file to form a complete certificate chain.
      copy /b your_domain_name_public.crt + your_domain_name_chain.crt your_domain_name_fullchain.pem

      After combining, you need only two files: your_domain_name_fullchain.pem and your_domain_name.key.

    2. Edit the configuration file.

      Open the SSL configuration file (for example, httpd-ssl.conf) and add the following:

      <VirtualHost *:443>
      
          # Replace example.com with the domain name that is bound to your certificate.
          ServerName example.com
      
          # Enable the SSL engine.
          SSLEngine on
      
          # Certificate file. Use the path to the actual combined certificate file (your_domain_name_fullchain.pem).
          # If you do not have an intermediate certificate file, use the path to the server certificate file (your_domain_name_public.crt).
          SSLCertificateFile D:\cert\your_domain_name_fullchain.pem
      
          # Private key file. Replace this with the path to your actual private key file.
          SSLCertificateKeyFile D:\cert\your_domain_name.key
      
          # Other configurations
          # ...
      
      </VirtualHost>

    Apache 2.4.7 and earlier

    Open the SSL configuration file (for example, httpd-ssl.conf) and add the following:

    <VirtualHost *:443>
    
        # Replace example.com with the domain name that is bound to your certificate.
        ServerName example.com
    
        # Enable the SSL engine.
        SSLEngine on
    
        # Certificate file. Replace this with the path to your actual certificate file.
        SSLCertificateFile D:\cert\your_domain_name_public.crt
    
        # Certificate chain file (specified separately). Replace this with the path to your actual intermediate certificate file.
        # If you do not have an intermediate certificate, you do not need to configure this directive.
        SSLCertificateChainFile D:\cert\your_domain_name_chain.crt
    
        # Private key file. Replace this with the path to your actual private key file.
        SSLCertificateKeyFile D:\cert\your_domain_name.key
    
        # Other configurations
        # ...
    
    </VirtualHost>
  3. Optional: Set up automatic HTTP-to-HTTPS redirection.

    Add the Rewrite directive to the <VirtualHost> block for your domain:

    <VirtualHost *:80>
        ServerName example.com
        RewriteEngine On
        RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    </VirtualHost>
  4. Save the configuration, navigate to the Apache bin directory, and check for syntax errors.

    .\httpd.exe -t

    Syntax OK confirms the configuration is correct. If an error is returned, fix it based on the error message.

  5. Restart the Apache service.

    After the syntax check passes, run the following command to restart Apache and apply the configuration.

    .\httpd.exe -k restart
    Note

    Alternatively, you can find and restart the Apache service in Windows Services (services.msc).

Step 4: Verify the deployment

  1. Access your domain name over HTTPS. Example: https://example.com. Replace example.com with your actual domain name.

  2. If a lock icon appears in the browser's address bar, the certificate is deployed successfully. If an access error occurs or the lock icon does not appear, clear your browser's cache or try again in incognito or private mode.

    image

    Starting with Chrome 117, the image icon in the address bar has been replaced by a new image icon. Click this icon to view the security lock information.

Note

If the issue persists, see the FAQ section for troubleshooting.

Deploying to production

When you deploy an application in a production environment, follow these best practices to improve security, stability, and maintainability:

  • Run the application as a non-administrator user:

    Create a dedicated, low-privilege system user for the application. Do not run the application by using an account that has administrative permissions.

    Note

    We recommend that you use a gateway-level SSL configuration. This involves deploying the certificate on a reverse proxy, such as an SLB or Nginx instance.

  • Externalize credential management:

    Do not hard-code sensitive information, such as passwords, in your code or configuration files. Use environment variables, a vault, or a Key Management Service provided by your cloud provider to inject credentials.

  • Enforce HTTP-to-HTTPS redirection:

    Make sure that all traffic that accesses your website over HTTP is automatically redirected to HTTPS. This helps prevent man-in-the-middle (MITM) attacks.

  • Configure modern TLS protocols:

    In your server configuration, disable obsolete and insecure protocols, such as SSLv3, TLS 1.0, and TLS 1.1. Enable only TLS 1.2 and TLS 1.3.

  • Monitor certificates and automate renewal:

    After the certificate is deployed, we recommend that you enable domain name monitoring. Alibaba Cloud automatically checks the validity period of the certificate and sends reminders before the certificate expires. This helps you renew the certificate in a timely manner to prevent service interruptions. For more information, see Purchase and enable public domain name monitoring.

FAQ

Certificate not working or HTTPS inaccessible

Common causes:

  • Port 443 is not open in the server's security group or firewall. For more information, see Step 2: Configure system and network settings.

  • The domain name does not match any domain in the certificate's Bound Domains. Check Domain name matching.

  • The Apache service was not restarted after the configuration change. Restart it as described in Step 3: Deploy the certificate.

  • The certificate files were not replaced correctly, or the configuration points to wrong paths. Verify that your certificate files and Apache configuration are current and valid.

  • The domain name is integrated with cloud services such as CDN, SLB, or WAF, but the certificate is not installed on the corresponding service. For more information, see Certificate deployment location when traffic passes through multiple cloud services.

  • The domain name resolves to multiple servers, but the certificate is installed on only some of them. You must install the certificate on each server.

Update or replace a certificate

Back up existing certificate files (.crt and .key). Download the new certificate from the SSL Certificate Service console, upload the files to the same paths and filenames on your server, and restart Apache.