The Apache HTTP Server is a open-source HTTP server for modern operating systems including UNIX and Windows. Apache provides a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.
This post details, how you can install and setup the apache webserver on Ubuntu.
Install Apache Webserver
$ sudo apt-get install apache2
Once above command is installed apache2 successfully without any error, you can see that apache server is running by following command as,
yt@dev:~$ systemctl status apache2.service ● apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; preset: enabled) Active: active (running) since Thu 2022-12-22 19:38:18 IST; 1min 17s ago Docs: https://httpd.apache.org/docs/2.4/ Main PID: 56091 (apache2) Tasks: 55 (limit: 9215) Memory: 5.5M CPU: 53ms CGroup: /system.slice/apache2.service ├─56091 /usr/sbin/apache2 -k start ├─56092 /usr/sbin/apache2 -k start └─56093 /usr/sbin/apache2 -k start Dec 22 19:38:18 dev systemd: Starting The Apache HTTP Server... Dec 22 19:38:18 dev apachectl: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the > Dec 22 19:38:18 dev systemd: Started The Apache HTTP Server.
Now, you can check that webserver is running by visiting its home page as http://localhost OR http://YOUR_IP in browser
So, this html index page displayed comes from /var/www/html on your machine, and you can check it as,
$ tree /var/www/html/ /var/www/html/ └── index.html 0 directories, 1 file
Now, if you want to have some of your custom web page displayed from this local server, just copy that to /var/www/html and it will be accessible from the browser as localhost/custom_webpage.html
Note: If you have seen an error like “systemd: Failed to start The Apache HTTP Server.” refer to our another post “Solved: systemd: Failed to start The Apache HTTP Server.” to fix this error.