Question

Setting Up SSL (HTTPS) to Server's Public Address Using Apache2

I have a problem when setting SSL to my server’s public address using Apache2 which I followed from this link, then the link asked me to access this link, and I ended up here.

The problem occurs when I’m trying to install Apache 2 by running

sudo apt install apache2

which returns an error

Job for apache2.service failed because the control process exited with error code.
                                                                                                                                                           See "systemctl status apache2.service" and "journalctl -xe" for details.
invoke-rc.d: initscript apache2, action "start" failed.
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2022-06-01 08:25:37 UTC; 18ms ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 26820 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)

After encountering that error, I tried googling for the solution and ended up with this first solution (by running the configtest command). Then the test came out that I have not set my ServerName right, so I tried setting it to my public IP address and restarted the apache2 system, but no luck. I still get the error even though the configtest came out only Syntax OK.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @felixmantaray,

You first need to install and configure Apache2 before you add SSL to your website. To do that check the following tutorial here:

https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-22-04

It should help you out with the installation and initial configuration. Once that’s done, you can use Let’s Encrypt(certbot) to automatically install an SSL certificate and have it deployed in apache2.

Hi there,

Indeed, for some reason, it looks like your Apache service is not starting.

I could suggest following the steps from this tutorial here on how to troubleshoot common Apache problems:

https://www.digitalocean.com/community/questions/how-to-troubleshoot-common-apache-issues-on-linux-server

Feel free to share the output of the commands from that tutorial here os I could try to advise you further.

Once your Apache service is up and running, you can install an SSL certificate as normal:

https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-20-04

Best,

Bobby