Ubuntu Apache configure https certificate

Server: Didi Cloud ECS

Environment: lamp (Ubuntu + Apache + mysql +php7)

Apply for a free SSL certificate#

Apply to the service provider where the domain name was originally located
Just choose the free type.

Enter the certificate console and download the certificate#

After the application is approved, download the certificate.

zip decompression#

Unzip four folders and a csr file.
The four folders (Apache, IIS, Nginx, Tomcat) are respectively the SSL certificates used by different server frameworks.

Copy the three folders in the Apache folder#

Install openssl

sudo apt-get install openssl

Turn on the ssl module##

enter
sudo a2enmod ssl
If invalid, enter the following two commands

sudo ln -s /etc/apache2/mods-available/ssl.load /etc/apache2/mods-enabled/ssl.load
sudo ln -s /etc/apache2/mods-available/ssl.conf /etc/apache2/mods-enabled/ssl.conf

Create a new folder and put the certificate into it##

mkdir /etc/apache2/cert

Configure HTTPS (SSL)

Enter /etc/apache2/ports.conf, check if there is

Listen 80
Listen 443

Add it if not

Modify the configuration file /etc/apache2/sites-enabled/000-default.conf

sudo vim /etc/apache2/sites-enabled/000-default.conf
Add to

< VirtualHost *:443>
 SSLEngine on
 SSLProtocol all -SSLv2 -SSLv3
 SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM
 SSLHonorCipherOrder on

 SSLCertificateFile cert/xxx_public.crt
 SSLCertificateKeyFile cert/xxx.key
 SSLCertificateChainFile cert/xxx_chain.crt

 ServerAdmin webmaster@localhost
 DocumentRoot project address
 ServerName www.xxx.com

 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined</VirtualHost>

Set http redirect to https

Open /etc/apache2/sites-available/000-default.conf,
Add the following three lines anywhere in the <\VirtualHost *:80><\VirtualHost> tag

RewriteEngine on
RewriteCond   %{HTTPS}!=on
RewriteRule   ^(.*)  https://%{SERVER_NAME}$1[L,R=301]

Just restart apache##

sudo service apache2 restart

Thanks##

HelpYourSelf!(https://www.cnblogs.com/yangfei123/p/10131961.html)
soha_dong(https://blog.csdn.net/soha_dong/article/details/92424562)

All rights reserved: 可定博客© WNAG.COM.CN

Title of this article: "Ubuntu Apache configuration https certificate"

Link to this article: https://wnag.com.cn/155.html

Special statement: Unless otherwise noted, all articles on this site are original. In principle, reprinting of articles on this site is prohibited. If you really want to reprint, please contact: [email protected], respect the achievements of others' labor, thank you~

Recommended Posts

Ubuntu Apache configure https certificate
Ubuntu configure Apache
Ubuntu configure Tomcat
How to configure Apache content caching on Ubuntu 14.04
ubuntu 14.04 configure 3-wire 3IP
Ubuntu configure network commands
Ubuntu18.10 configure Java environment
Ubuntu 18.10 configure Nvidia driver
Ubuntu configure SecureCRT login
Detailed steps to configure Ubuntu 16.04 and Apache virtual host
Configure tomcat on ubuntu server
ubuntu install and configure GitLab
How to install https certificate (ubuntu+apache2)
How to install Apache on Ubuntu 20.04
Install and configure MySQL on Ubuntu
Install and configure Docker in Ubuntu
ubuntu modify and configure ip address
How to install Apache on Ubuntu 20.04
Configure ring after installation on Ubuntu 16.04
Nginx-ubuntu install Nginx and configure https