apt install apache2
How to install the Apache HTTP server on Debian and Ubuntu based systems.

By. Jacob
Edited: 2024-03-12 18:48
Quick-reference:
sudo apt install apache2
Installing Apache on Ubuntu and Debian
The apt install apache2 command is used to install Apache2 on Debian and Ubuntu based systems, this is just a reminder on how to install the Apache HTTP web server.
You probably also need to enable dependencies after installing Apache. E.g. mod_rewrite.
To enable individual modules use a2enmod. E.g. To enable mod_rewrite use the following:
sudo a2enmod rewrite
To disable it again use a2dismod:
sudo a2dismod rewrite
You should also remember to reload or restart apache after making changes. E.g:
sudo systemctl reload apache2
Typical needed modules
If you use server-sided scripting (E.g. PHP or Python), you may also need to enable the FastCGI protocol; to do so, you need to enable both mod_proxy and mod_proxy_fcgi. E.g:
sudo a2enmod proxy_http
sudo a2enmod proxy_fcgi
Then, do not forget to add other relevant services to your server. E.g. Install PHP-FPM if you wish to run PHP code:
apt install php8.2-fpm
Finally, enabling relevant configuration to handle PHP scripts with PHP-FPM is equally straight forward:
sudo a2enconf php8.2-fpm
Tell us what you think: