Apache add new site as subdomain on server
Name Based Virtual Hosting uses the hostname your web browser sends as part of the HTTP request to identify which VirtualHost will be used to answer the request.
Typically you need to set up DNS for that and point both site1.example.com
and site2.example.com
to the IP-address of your webserver.
For a single user / developer, you can avoid registrering a domain and setting up DNS records by adding those two host names to the hosts file of your workstation.
If you have multiple IP-addresses available (nowadays rarely in the IPv4 world but commonly in IPv6) you can bind each Apache VirtualHost entry to different IP-address and don't need either DNS or the hosts file to serve different content, simply access the correct IP-address
https://httpd.apache.org/docs/current/vhosts/name-based.html#namevip