This tutorial will enable you to to put in Apache net server on Ubuntu 20.04 LTS (Focal Fossa) working system. Additionally, you will learn to safe your area utilizing Let’s encrypt SSL certificates. This tutorial will even work on Ubuntu 18.04, Ubuntu 16.04 and Ubuntu 19.10 Linux techniques.

Earlier than We Begin

Earlier than start your work:

  • Working Ubuntu 20.04 system with sudo privileges shell entry.
  • Full preliminary server setup directions
  • A website title registered and pointed to your server’s public IP tackle. For this tutorial, we use webhost.tecadmin.web, which is pointed to our server.

Step 1 — Putting in Apache

Apache packages can be found below the default software program repositories on Ubunts. You may simply set up it utilizing the standard package deal administration device.

To start with, replace the native package deal index to replicate the most recent upstream modifications. Then set up Apache2 net server.

sudo apt replace
sudo apt set up apache2

After the affirmation, apt will set up Apache and different required dependencies in your system.

Step 2 — Check Your Net Server

As soon as the set up completed, Apache service will robotically begin in your Ubuntu system. You’ll find the Apache service standing by operating the next command:

sudo systemctl standing apache2

Pattern output:

● apache2.service – The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Energetic: lively (operating) since Solar 2020-04-26 05:28:08 UTC; 10min in the past
Docs: https://httpd.apache.org/docs/2.4/
Essential PID: 15464 (apache2)
Duties: 55 (restrict: 2283)
Reminiscence: 6.9M
CGroup: /system.slice/apache2.service
├─15464 /usr/sbin/apache2 -k begin
├─18646 /usr/sbin/apache2 -k begin
└─18647 /usr/sbin/apache2 -k begin

Apr 26 05:28:08 tecadmin systemd[1]: Beginning The Apache HTTP Server…
Apr 26 05:28:08 tecadmin systemd[1]: Began The Apache HTTP Server.

The consequence standing like “Energetic: lively (operating)” means Apache service have began efficiently. Nevertheless, the easiest way to check net server, request a web page from Apache in net browser.

How to Secure and Install Apache on Ubuntu 20.04 – TecAdmin

You will note the default Apache touchdown web page. It means the Apache net server is operating correctly in your system.

Step 3 — Create A Digital Host

With the assistance of digital hosts, you’ll be able to host multiple area from a single server. A digital host encapsulate the configuration of a site to it. We’ll arrange a digital host with a sub-domain known as webhost.tecamin.web, however you must substitute this with your personal area title.

Let’s begin with a listing for our area as follows:

sudo mkdir /var/www/webhost
sudo chmod -R 755 /var/www/webhost
sudo chown -R www-data:www-data /var/www/webhost

Subsequent, create a pattern index.html web page to host on this subdomain. Edit this file in your favourite textual content editor like vim or nano:

nano /var/www/webroot/index.html

Add the next pattern HTML content material:

Save file and shut it.

With the newly put in Apache server, you will note a default digital host configuration file positioned at and so on/apache2/sites-available/000-default.conf. However that is an good habbit to create seperate configuration file for every digital host. So create a brand new digital host file as /and so on/apache2/sites-available/webhost.tecadmin.web.conf:

sudo nano /and so on/apache2/sites-available/webhost.tecadmin.web.conf

Add the next configuration to digital host file. Make certain to alter the correct ServerAdmin electronic mail tackle, Servername to your area title. You may as well embody ServerAlias so as to add extra area or subdomains. Then set appropriate DocumentRoot as created above.

Save file and shut it.

By default Apache reads digital host configuration information below /and so on/apache2/sites-available listing. Use a2ensite device to allow this digital host:

sudo a2ensite webhost.tecadmin.web.conf

The above command will create a symbolic hyperlink webhost.tecadmin.web.conf file to sites-available listing.

As soon as executed, run the under command to confirm the configuration information:

sudo apache2ctl configtest

You need to see the next output:

Syntax OK

Subsequent, Restart Apache service to use your modifications:

sudo systemctl restart apache2

Apache is able to serve your content material in your configured area title. You may take a look at this by navigating to http://webhost.tecadmin.web,

Step 4 — Configure Let’s Encrypt SSL

We use Let’s encrypt SSL certificates to safe web site on Apache net server. Certbot is the command line utility to work with Let’s encrypt certificates. Run the next command to put in certbot binary:

sudo apt set up python3-certbot-apache

It will set up all of the required packages for the certbot.

As soon as the set up course of completed. Run the under command to request let’s encrypt certificates authority to challenge certificates for our area webhost.tecadmin.web. You may add a number of domains or subdomains utilizing separate “-d” parameters.

certbot -d webhost.tecadmin.web

Wizard will ask your electronic mail tackle to ship your updates. Then settle for Phrases of Service to proceed. Beneath is the whole logs of command:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins chosen: Authenticator apache, Installer apache
Enter electronic mail tackle (used for pressing renewal and safety notices) (Enter ‘c’ to
cancel): [email protected]

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Please learn the Phrases of Service at
https://letsencrypt.org/paperwork/LE-SA-v1.2-November-15-2017.pdf. You will need to
agree so as to register with the ACME server at
https://acme-v02.api.letsencrypt.org/listing
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
(A)gree/(C)ancel: A

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Would you be keen to share your electronic mail tackle with the Digital Frontier
Basis, a founding companion of the Let’s Encrypt venture and the non-profit
group that develops Certbot? We would prefer to ship you electronic mail about our work
encrypting the online, EFF information, campaigns, and methods to assist digital freedom.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
(Y)es/(N)o: Y
Acquiring a brand new certificates
Performing the next challenges:
http-01 problem for webhost.tecadmin.web
Enabled Apache rewrite module
Ready for verification…
Cleansing up challenges
Created an SSL vhost at /and so on/apache2/sites-available/webhost.tecadmin.net-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificates to VirtualHost /and so on/apache2/sites-available/webhost.tecadmin.net-le-ssl.conf
Enabling accessible website: /and so on/apache2/sites-available/webhost.tecadmin.net-le-ssl.conf

Please select whether or not or to not redirect HTTP visitors to HTTPS, eradicating HTTP entry.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
1: No redirect – Make no additional modifications to the webserver configuration.
2: Redirect – Make all requests redirect to safe HTTPS entry. Select this for
new websites, or for those who’re assured your website works on HTTPS. You may undo this
change by enhancing your net server’s configuration.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Choose the suitable quantity [1-2] then [enter] (press ‘c’ to cancel): 2
Enabled Apache rewrite module
Redirecting vhost in /and so on/apache2/sites-enabled/webhost.tecadmin.web.conf to ssl vhost in /and so on/ap ache2/sites-available/webhost.tecadmin.net-le-ssl.conf

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Congratulations! You may have efficiently enabled https://webhost.tecadmin.web

You need to take a look at your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=webhost.tecadmin.web
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

IMPORTANT NOTES:
– Congratulations! Your certificates and chain have been saved at:
/and so on/letsencrypt/reside/webhost.tecadmin.web/fullchain.pem
Your key file has been saved at:
/and so on/letsencrypt/reside/webhost.tecadmin.web/privkey.pem
Your cert will expire on 2020-07-25. To acquire a brand new or tweaked
model of this certificates sooner or later, merely run certbot once more
with the “certonly” possibility. To non-interactively renew *all* of
your certificates, run “certbot renew”
– Your account credentials have been saved in your Certbot
configuration listing at /and so on/letsencrypt. You need to make a
safe backup of this folder now. This configuration listing will
additionally include certificates and personal keys obtained by Certbot so
making common backups of this folder is right.
– In case you like Certbot, please contemplate supporting our work by:

Donating to ISRG / Let’s Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le

You may have efficiently configured you area with SSL certificates. Now, you’ll be able to entry your area over https protocol as proven within the screenshot under:

How to Secure and Install Apache on Ubuntu 20.04 – TecAdmin

Step 5 — Regulate Firewall Guidelines

You need to use the service title like “http” or “https” to permit in FirewallD. To open HTTP and HTTPS port in FirewallD run the under instructions:

sudo firewall-cmd –permanent –add-service=http
sudo firewall-cmd –permanent –add-service=https

When you add the principles, reload modifications utilizing the next command.

sudo firewall-cmd –reload

Step 6 — Handle Apache Service

Now, you’ve gotten your Apache net server up and operating, let’s go along with the Apache service administration instructions.

To cease Apache net server, kind:

sudo systemctl cease apache2

To start out Apache net server (if stopped), kind:

sudo systemctl begin apache2

To restart (cease after which begin) Apache service, kind:

sudo systemctl restart apache2

As a substitute of cease then begin a operating server, use reload possibility to use configuration file modifications with out dropping present connections. However this is not going to learn any new configuration file:

sudo systemctl reload apache2

To disable Apache service to auto begin on system boot, kind:

sudo systemctl disable apache2

To allow Apache service to auto begin on system boot, kind:

sudo systemctl allow apache2

Conclusion

The Apache net server is operating in your Ubuntu 20.04 LTS working system.

ubuntu 20.04 httpd,enable ssl apache2,ubuntu 20 web server,apache2 ssl virtual host,apache2 https,digitalocean ubuntu 20,ubuntu 20.04 install lamp stack,install php apache ubuntu 20