Kodename JPG
IDEN

Configuring an Apache Virtual Host on Arch Linux


Written: Jun 12, 2021 · Level: Beginner · Category: Linux


Home > Tutorial > Configuring an Apache Virtual Host on Arch Linux

بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم




The term Virtual Host refers to the practice of running more than one website (such as company1.example.com and company2.example.com) on a single machine. Virtual hosts can be 'IP-based', meaning you have a different IP address for each website, or 'name-based', meaning you have several names running on each IP address. The fact that they run on the same physical server is invisible to the end user. Apache was one of the first servers to support IP-based virtual hosts directly. Apache version 1.1 and later support both IP-based and name-based virtual hosts (vhosts). The latter variant of virtual hosts is also sometimes called host-based or non-IP virtual hosts.

Configuration



First, edit the file at /etc/httpd/conf/httpd.conf:
sudo nano /etc/httpd/conf/httpd.conf

then uncomment the following line:
Include conf/extra/httpd-vhosts.conf

then configure the hosts file:
sudo /etc/hosts

img1

then create a vhosts folder:
sudo mkdir /etc/httpd/conf/vhosts

next, create a file in the vhosts folder, with the file name matching the name in hosts:
sudo nano /etc/httpd/conf/vhosts/contoh.dom

img2

enable the v-host by adding the following to /etc/httpd/conf/httpd.conf:
Include conf/vhosts/contoh.dom

img3

once done, restart httpd:
sudo systemctl restart httpd

Open http://contoh.dom in your browser:
img4

Hope this helps.

References



  1. https://wiki.archlinux.org/title/Apache_HTTP_Server#Virtual_hosts
  2. https://httpd.apache.org/docs/2.4/vhosts/

Like this tutorial? Support the author so there are more free tutorials.

Support via Saweria

Comments