To build a public website, you need two main components:
- A Hosting account
- A domain name
The hosting account is a server or a portion of a server where you can host your website files, multimedia, databases, emails, etc. While the domain name is the address of the website/emails.
While some Hosting Providers offer free trials for a hosting plan (generally with a very limited access), you cannot possibly have a free domain name as there are always registrar fees to register new domains. What you can have instead is a sub-domain (something like test.serverfault.com). This would allow you to build a website and make it accessible for public visitors.
Shared Hosting plans usually come with a control panel (like cPanel and Plesk). These are user interfaces with the most used apps to help you build your website and manage your web services. So as a beginning, I would recommend ordering a domain name and a short-term shared hosting plan (cPanel is very user-friendly compared to other control panels). this would cost like 10$ for the domain (1-year registration) and 5-8$/mo for the hosting (depending on the Host).
For development just on your own network, you can host all of the server components yourself, usually with open-source components. And you don't need a domain name - you can just use LAN names like https://localhost or https://127.0.0.1.