Install the Apache Web Server on Ubuntu 18.04, 12.04
Apache is a popular open-source, cross-platform web server that is, by the numbers, the most popular web server in existence. In this quickstart article, we'll see how to install Apache server on Ubuntu, Debain.
Table of Contents
- Install Apache
- Adjust Firewall
- Check Webserver
- Add Virtual Host
Install Apache
Update your packages:
Now install Apache:
Then enable and start webserver:
Adjust Firewall
First, check firewall is enabled or not:
If status is "active", then allow apache to server traffic:
Check Webserver
Run this command to check website is running or not:
If it is running, you'll see an output like:
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Tue 2022-04-15 12:12:31 UTC; 7min ago
Main PID: 2583 (apache2)
Tasks: 55 (limit: 1153)
CGroup: /system.slice/apache2.service
├─2583 /usr/sbin/apache2 -k start
├─2585 /usr/sbin/apache2 -k start
└─2586 /usr/sbin/apache2 -k start
Now you can access default Apache webpage by visiting your server IP:
Add Virtual Host
In one server, we can host unlimited websites. It is called virtaul host/s. Let's add a domain:
Create the directory for your domain test.com
:
Assign ownership:
Set permissions:
Create a sample index.html page:
Demo content:
Now, create a new virtual host config file at location /etc/apache2/sites-available
for domain test.com:
And insert the follwing config block:
Save and close the config file. Then enable your virtual host file:
Test for configuration errors:
Disable the default site (optional):
Finally restart Apache:
Now visit your domain http://test.com
.
That's all. Thanks for reading. 👍