Apache HTTP Server is one of the two dominant web servers running the modern internet (alongside Nginx) — it's the software that actually receives an incoming HTTP request on a given server and decides what to do with it: serve a static file, hand it off to PHP, or proxy it somewhere else.
Installing Apache on Ubuntu
sudo apt update
sudo apt install apache2
Verifying it's running
sudo systemctl status apache2
Visiting the server's IP address in a browser should show Apache's default "It works!" placeholder page once the service is confirmed running.
Starting, stopping, and restarting the service
sudo systemctl start apache2
sudo systemctl stop apache2
sudo systemctl restart apache2
sudo systemctl reload apache2
reload re-reads the configuration without dropping active connections — the better choice after a config change on a live server, versus a full restart, which briefly takes the server offline.
Enabling Apache to start on boot
sudo systemctl enable apache2
The default document root and virtual host
Apache serves files from /var/www/html by default, configured through a virtual host file, typically at /etc/apache2/sites-available/000-default.conf — this is where the document root, server name, and other per-site settings live.
Enabling mod_rewrite for frameworks like Laravel
sudo a2enmod rewrite
sudo systemctl restart apache2
Laravel's routing (and most modern PHP frameworks') depends on URL rewriting to route all requests through a single front controller — without mod_rewrite enabled, only the framework's home page tends to load correctly while every other route 404s.
Checking the Apache error log when something goes wrong
sudo tail -f /var/log/apache2/error.log
This is usually the first place to look when a page returns a 500 error or Apache won't start after a config change — it typically names the exact config file and line causing the problem.
Apache vs. Nginx, briefly
Both are capable, widely-used production web servers — Apache's .htaccess per-directory configuration files offer flexibility that shared hosting environments often rely on, while Nginx is generally considered to handle very high concurrent connection counts somewhat more efficiently; the choice for most typical applications comes down to hosting environment defaults and team familiarity more than a decisive technical gap between them.