
Configure Apache With TLS/SSL Certificate on Ubuntu 18:
Posted on |
Are you looking to configure Apache to enable SSL Apache 2 Ubuntu with TLS/SSL certificate? Dataservermarket will provide you with a step-by-step guide to enable SSL Apache 2 Ubuntu in detail. Before diving into the article which describes how to configure Apache to enable SSL Apache 2 Ubuntu, Dataservermarket wants you to understand the overview of Apache and how to enable SSL Apache 2 Ubuntu.
Overview of Apache and how to enable SSL Apache 2 Ubuntu explained by Dataservermarket:
SSL (Secure Socket Layer) and TLS (Secure Socket Layer) are utilized for assuring data transfer between the server and client. Dataservermarket suggests that these certificates add an extra security layer which you previously sent in the form of plain text can now be analyzed by a third party. The tutorial will help activate Apache and enable SSL Apache 2 Ubuntu 18.
Generating the Apache server and helping to enable SSL Apache 2 Ubuntu 18 by yourself means you will be a signer and won’t be able to verify the identity. It will warn the Apache user about the certificate’s validity. However, Dataservermarket suggests that it is possible to bypass the certificate. Public-facing sites must enable SSL Apache 2 Ubuntu 18 on the Apache server.
Let’s look at the pre-requisites of configuring Apache and enable SSL Apache 2 Ubuntu 18 by Dataservermarket.
Pre-requisites to enable SSL Apache 2 Ubuntu 18:
- Dataservermarket suggests that to enable SSL Apache 2 Ubuntu 18, you need to have the Apache server installed and configured.
Detailed and comprehensive guide to enable SSL Apache 2 Ubuntu 18 on the Apache server by Dataservermarket:
Let’s dive into the detailed and step-by-step guide to enable SSL Apache 2 Ubuntu 18 on the Apache server is as follows:
Step 1: Generate Certificate:
Create a directory to store the file on the Apache server to enable SSL Apache 2 Ubuntu 18 by issuing the following command:
$ mkdir ~/certificates
$ cd ~/certificates
Generate CSR to store the file on the Apache server to enable SSL Apache 2 Ubuntu 18 by issuing the subsequent order:
$ openssl req -x509 -newkey rsa:4096 -keyout apache.key -out apache.crt -days 365 -nodes
By successfully issuing the command on the Apache server to enable SSL Apache 2 Ubuntu 18, the server will ask for the information request of the certificate. Dataservermarket recommends completing it using the appropriate information.
Country Name (2 letter code) [AU]: IN
State or Province Name (full name) [Some-State]: MH
Locality Name (eg, city) []: BHY
Company’s Name (eg, company) [My Company]: My Company
Organizational Unit Name (eg, section) []:
The common name on the Apache server to enable SSL Apache 2 Ubuntu 18 is the domain name or the server’s IP Address:
Common Name (e.g. server or YOUR name) []: 192.168.4.2
Email Address []: example@example.com
The next step to enable SSL Apache 2 Ubuntu 18 on the Apache server is moving the certificate to the same folder by issuing the following commands:
$ mkdir /etc/apache2/ssl
$ mv ~/certificates/* /etc/apache2/ssl/.
After successfully running the command to enable SSL Apache 2 Ubuntu 18, we will make the certificate work on the Apache server as suggested by Dataservermarket.
Step 2: Configuring the Firewall:
To enable SSL Apache 2 Ubuntu 18 on the Apache server, make sure to open TCP Port 443. Dataservermarket suggests using Port 443 instead of Port 80 SSL.
To enable SSL Apache 2 Ubuntu 18 and UFW on the Apache server, issue the following command suggested by Dataservermarket.
$ sudo ufw enable
To enable SSL in Apache, allow pre-defined Apache settings for the firewall using the following command:
$ sudo ufw allow ‘Apache Full’
To enable SSL in Apache, you may check the list of current rules and issue the following command:
$ sudo ufw status
The configuration should be similar to the one mentioned below to enable SSL in Apache.
To Action From
— —— —-
Apache Full ALLOW Anywhere
OpenSSH ALLOW Anywhere
Apache Full (v6) ALLOW Anywhere (v6)
OpenSSH (v6) ALLOW Anywhere (v6)
To allow future connections, click on enable SSH to enable SSL in Apache:
$ sudo ufw allow ‘OpenSSH.’
Step 3: Apache virtual host configuration to enable SSL in Apache:
To enable SSL in Apache, navigate to the default Apache site configuration directory by issuing the following command:
$ sudo nano /etc/apache2/sites-available/default-ssl.conf
The config tells the server to find an SSL certificate to enable SSL in Apache.
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
<FilesMatch “.(cgi|shtml|phtml|php)$”>
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
</IfModule>
The commands and results to enable SSL in Apache should look like this.
Edit this: ServerAdmin webmaster@localhost to this:
ServerAdmin email@example.net
To enable SSL in Apache, add this right below the server admin streak:
ServerName DOMAIN_NAME_HERE_OR_ADD_YOUR_IP
Directly revise the below lines to enable SSL in Apache at certificate locations.
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
The file should look like this:
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin email@example.net
ServerName 203.0.113.122
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
<FilesMatch “.(cgi|shtml|phtml|php)$”>
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
</IfModule>
To enable SSL in Apache, save the file and close it.
Step 4: Enable SSL in Apache server:
Enable SSL in Apache using the following server:
$ sudo a2enmod ssl
Now to enable SSL in Apache, promote the site we have edited:
Restart Apache to enable SSL in Apache server:
$ sudo service apache2 restart
The website has enable SSL in Apache and is now secured.
You can go through it using the following address in your search bar, which is as follows:
Since the browser will make the certification invalid, you need to follow certain proceedings for your browser to proceed. It is because the SSL or TSL is not yet signed.
Wrapping up:
We hope you understood the detailed and comprehensive guide that provided a step-by-step configuration of the with TLS/SSL certificate and to enable SSL Apache 2 Ubuntu 18 explained by Dataservermarket.
Read More Blogs Related to the topic
- How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 18.04
- Install or upgrade to latest Linux Kernel on Ubuntu 20.04 & Linux Mint 20
- How to Install and Configure vsftpd on Ubuntu 18.04