Apache2 is a one of the two notorious & popular webserver programs, and for good reason, here's how to install apache2 onto your Ubuntu 20.04 (Focal Fossa) device in 4 easy steps!
(1) Update Repositories using apt
Run the following command in your console to update any repositories and packages on your server instance:
sudo apt update
Note: if you want to skip using sudo and typing your password every time, run (root can skip sudo at all times without sudo -i):
(2) Install Apache2 itself
Now, install the apache2 package by running:
sudo apt install apache2
(3) Useful console commands for apache2
To start the apache2 service:
sudo systemctl start apache2
To make apache2 boot from startup automatically:
sudo systemctl enable apache2
To disable apache2 booting up from startup automatically:
sudo systemctl disable apache2
To stop the apache2 service:
sudo systemctl stop apache2
To reload the apache2 service, for instance after changes:
sudo systemctl reload apache2
To restart the apache2 service:
sudo systemctl restart apache2
(4) Configure firewalling for apache2
Go to your KUBBUR VPS panel's "FIREWALL" page and press "NEW RULE" for this modal to show up:
And fill in: Name can be anything you want (apache2 port for example), Source IP is the IP that is allowed to connect to the port (you can restrict this to your own IP for example, leave blank for no restriction), Destination IP should be the IP of your Virtual Server and Protocol is set to 'UDP', Source Port to as previously noted whatever you want to restrict it to (leave blank for no restrictions) and the Destination Port to the apache2 port you chose, default is 443, and Action is set to "ALLOW".
Then make another rule doing the exact same but making the Destination Port 80.
And you should be all done!