简体   繁体   中英

How to install SSL certificate in apache server in ubuntu

I want enter localhost like a https://localhost , I need to do this with ssl. How to install SSL certificate in apache server in ubuntu?

Thanks in advance

You have to add your certificate to your httpd.conf file in the VirtualHost section and change the port to 433. A Minimal config looks like this:

LoadModule ssl_module modules/mod_ssl.so
Listen 443
<VirtualHost *:443>
    # maybe additional config here

    ServerName www.example.com

    SSLEngine on
    SSLCertificateFile "/path/to/www.example.com.cert"
    SSLCertificateKeyFile "/path/to/www.example.com.key"

</VirtualHost>

The httpd.conf should be in /etc/httpd , /etc/apache/ or similar.

Restart the server afterwards.

More information on Apache Server SSL .

Ubuntu doesn't use httpd.conf as standard, instead global configuration stuff for apache is found in /etc/apache2/apache2.conf . You can create a httpd.conf in the apache2 directory, and load any further configuration from it by including the following line in /etc/apache2/apache2.conf.

The following steps are based on Ubuntu server with Apache2. Step 1: Copy/paste your SSL certificate files to the server.

Download your Intermediate Certificate (CertificateAuthority.cert) and SSL Certificate (Example_Your_Domain.cert) from your Certificate Authority (such as Symantec, GeoTrust, RapidSSL or Thawte).

Copy the Intermediate Certificate and SSL Certificate to the directory on the server where you will keep the certificate and key files. Make them readable by root only.

Step 2: Locate the Apache configuration file to editing. Generally in Ubuntu's Apache the configuration file can be found in; /etc/apache2/sites-enabled/example_your_domain

Note: If you are unable to find the configuration file on the folder location “sites-enabled” then you must run the following command “sudo a2ensite example_your_domain” Open the configuration file with a text editor and locate blocks that contain Apache setting.

Step 3: Find the SSL block to configure. If your intention to access your website using both “https” and “http” connections, then you need two separate files in /etc/apache2/sites-enabled/. One is for port 80 and another for port 443.

Step 4: Configure the block for the “SSL-enabled” website. Here is an example of a virtual host configured for SSL certificate connection. The parts in bold letters must be configured to established secure connection of HTTPS on Ubuntu Server with Apache2

DocumentRoot /var/www/ 
SSLEngine on 
SSLCertificateFile /path/to/example _your _domain.crt 
SSLCertificateKeyFile /path/to/your_private.key 
SSLCertificateChainFile /path/to/CertificateAuthority.crt

Make your file names match your certificate files, such as; SSLCertificateFile is your certificate file (eg. example_your_domain.crt). SSLCertificateKeyFile is your key file that you generated while creation of the CSR. SSLCertificateChainFile is the Certificate Authority intermediate certificate file (Symantec.crt)

Step 5: That's it! Restart Apache Now!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM