free Let’s Encrypt alternatives<\/a>.<\/p>\nExecute the following command to install Apache2:<\/p>\n
sudo apt install apache2<\/pre>\nOnce Apache2 is installed on your server, you will be able to use the commands below to start, stop, and enable the service. We recommend enabling it so that Apache can start up automatically whenever your server reboots.<\/p>\n
sudo systemctl stop apache2.service\r\nsudo systemctl start apache2.service\r\nsudo systemctl enable apache2.service<\/pre>\nTo confirm that you have properly installed Apache2, you can open your preferred web browser and type your server IP address or your domain (we assume it is pointed to your server) and you should be able to view the Apache2 Ubuntu Default Page.<\/p>\n
<\/span>3. Configure the Apache Virtual Host<\/span><\/h2>\nSince you now have Apache installed on your server, we can continue and show you how to create a virtual host for the domain that you want to use. We will use nano as our editor, but if you do not prefer nano, you can use any editor of your choice and create a new configuration file called domain.com.conf<\/code>.<\/p>\nsudo nano \/etc\/apache2\/sites-available\/domain.com.conf<\/pre>\nThen paste the configuration from below into the file, and replace all occurrences of\u00a0domain.com<\/code> with your actual domain name.<\/p>\n<VirtualHost *:80>\r\n\r\nDocumentRoot \/var\/www\/html\/domain.com\r\nServerName domain.com\r\nServerAlias www.domain.com\r\n\r\n<Directory \/var\/www\/html\/domain.com\/>\r\nOptions FollowSymlinks\r\nAllowOverride All\r\nRequire all granted\r\n<\/Directory>\r\n\r\nErrorLog ${APACHE_LOG_DIR}\/error.log\r\nCustomLog ${APACHE_LOG_DIR}\/access.log combined\r\n\r\n<\/VirtualHost><\/pre>\nAfter you have finished with editing the file, save and close it.<\/p>\n
Once you have configured the virtual host, you can enable it by executing the following commands.<\/p>\n
Disable the default preinstalled virtual host with:<\/p>\n
sudo a2dissite 000-default<\/pre>\nthen, enable the domain.com<\/code> virtual host:<\/p>\nsudo a2ensite domain.com.conf<\/pre>\nalso, you need to make sure that the mod rewrite<\/code> is enabled:<\/p>\nsudo a2enmod rewrite<\/pre>\nRestart Apache so the changes will take effect.<\/p>\n
sudo systemctl restart apache2.service<\/pre>\n<\/span>4. Install Certbot<\/span><\/h2>\nAs mentioned earlier, we will be using Certbot so that we can get a free SSL certificate from Let’s Encrypt. To install this useful tool, we need to enable the universe<\/code> repository:<\/p>\nsudo apt install software-properties-common\r\nsudo add-apt-repository universe\r\nsudo apt update<\/pre>\nRun this command on the command line on the machine to install Certbot.<\/p>\n
sudo apt install certbot python3-certbot-apache<\/pre>\n<\/span>5. Generate a Free Let\u2019s Encrypt SSL Certificate<\/span><\/h2>\nThere are many ways to obtain an SSL certificate with Certbot. We will use the Apache plugin, which will take care of reconfiguring Apache’s Virtual Host and will reload the new configuration for us. You can run the following command to use the plugin:<\/p>\n
sudo certbot --apache<\/pre>\nUsing this script, you need to answer a series of questions and provide an email address. In the first step, you need to type a valid email address. The email address is required for notifications and security notices regarding your website’s certificate:<\/p>\n
Output:\r\nSaving debug log to \/var\/log\/letsencrypt\/letsencrypt.log\r\nPlugins selected: Authenticator apache, Installer apache\r\nEnter email address (used for urgent renewal and security notices) (Enter 'c' to\r\ncancel): you@domain.com<\/pre>\nThe next step is to confirm that you agree to the Let\u2019s Encrypt terms of service. If you want to confirm, just type A and then press [ENTER]:<\/p>\n
Output:\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nPlease read the Terms of Service at\r\nhttps:\/\/letsencrypt.org\/documents\/LE-SA-v1.2-November-15-2017.pdf. You must\r\nagree in order to register with the ACME server at\r\nhttps:\/\/acme-v02.api.letsencrypt.org\/directory\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n(A)gree\/(C)ancel: A<\/pre>\nIf you want to share the provided email address with the EFF (Electronic Frontier Foundation) to receive news and other information, you can type Y. If you do not want to receive this type of email, you can type N and submit your answer by typing [ENTER].<\/p>\n
Output:\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nWould you be willing to share your email address with the Electronic Frontier\r\nFoundation, a founding partner of the Let's Encrypt project and the non-profit\r\norganization that develops Certbot? We'd like to send you email about our work\r\nencrypting the web, EFF news, campaigns, and ways to support digital freedom.\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n(Y)es\/(N)o: N<\/pre>\nNow you need to select the domain you would like to activate HTTPS for. The domains and subdomains listed on your command prompt are automatically obtained from your Apache virtual host configuration. Type the numbers separated by commas and\/or spaces, or if you’d like to enable HTTPS for all of the domains or subdomains, you can leave the prompt blank. Either way, you then press [ENTER] to proceed to the next step.<\/p>\n
Output:\r\nWhich names would you like to activate HTTPS for?\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n1: domain.com\r\n2: www.domain.com\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nSelect the appropriate numbers separated by commas and\/or spaces, or leave input\r\nblank to select all options shown (Enter 'c' to cancel):<\/pre>\nThe output will be similar to this:<\/p>\n
Output:\r\nObtaining a new certificate\r\nPerforming the following challenges:\r\nhttp-01 challenge for domain.com\r\nhttp-01 challenge for www.domain.com\r\nWaiting for verification...\r\nCleaning up challenges\r\nCreated an SSL vhost at \/etc\/apache2\/sites-available\/domain.com-le-ssl.conf\r\nDeploying Certificate to VirtualHost \/etc\/apache2\/sites-available\/domain.com-le-ssl.conf\r\nEnabling available site: \/etc\/apache2\/sites-available\/domain.com-le-ssl.conf<\/pre>\nCertbot provides HTTPS redirection as an option that you can enable. In this step, the script will prompt you to select if you want the entire HTTP traffic to be redirected to HTTPS or to keep the current configuration. Select 1 if you do not want redirection or 2 to enable redirection, then press [ENTER].<\/p>\n
Output:\r\nPlease choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n1: No redirect - Make no further changes to the webserver configuration.\r\n2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for\r\nnew sites, or if you're confident your site works on HTTPS. You can undo this\r\nchange by editing your web server's configuration.\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nSelect the appropriate number [1-2] then [enter] (press 'c' to cancel): 2<\/pre>\nGreat job. Your SSL certificate is now installed and loaded in the Apache configuration. You will see output similar to the following:<\/p>\n
Output:\r\nRedirecting vhost in \/etc\/apache2\/sites-enabled\/domain.com.conf to ssl vhost in \/etc\/apache2\/sites-available\/domain.com-le-ssl.conf\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nCongratulations! You have successfully enabled https:\/\/domain.com\r\n\r\nYou should test your configuration at:\r\nhttps:\/\/www.ssllabs.com\/ssltest\/analyze.html?d=domain.com\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n\r\nIMPORTANT NOTES:\r\n- Congratulations! Your certificate and chain have been saved at:\r\n\/etc\/letsencrypt\/live\/domain.com\/fullchain.pem\r\nYour key file has been saved at:\r\n\/etc\/letsencrypt\/live\/domain.com\/privkey.pem\r\nYour cert will expire on 2021-09-09. To obtain a new or tweaked\r\nversion of this certificate in the future, simply run certbot again\r\nwith the \"certonly\" option. To non-interactively renew *all* of\r\nyour certificates, run \"certbot renew\"\r\n- Your account credentials have been saved in your Certbot\r\nconfiguration directory at \/etc\/letsencrypt. You should make a\r\nsecure backup of this folder now. This configuration directory will\r\nalso contain certificates and private keys obtained by Certbot so\r\nmaking regular backups of this folder is ideal.\r\n- If you like Certbot, please consider supporting our work by:\r\n\r\nDonating to ISRG \/ Let's Encrypt: https:\/\/letsencrypt.org\/donate\r\nDonating to EFF: https:\/\/eff.org\/donate-le<\/pre>\nTo verify that your new SSL certificate is set up correctly, visit https:\/\/domain.com\/<\/code> in your web browser and check for the green lock icon in the URL bar. You can also use an external website or tools to check if your SSL certificate is installed properly.<\/p>\n