I have an apache server in a vps, and in the / path / apache2 / sites-available folder I have the config of my web page.
How can I do to not have to enter the ip? Do I have to buy a domain?
It depends on where you buy the domain, if you have an internal DNS etc. The most basic and general configuration that you can suggest is once you buy the domain you must edit the DNS Zone, add a record A, placing in name or host the value www and as a value place the public IP from your server.
So if you buy the domain marc.com when you add the record A mentioned, you will have www.marc.com that resolves to your public IP.
Depending on what company you have purchased, they will put at your disposal some tool or interface from where you can manage your domain, for example, you can do it in godaddy , or in CPanel
Depends on the OS of the server, for example
Debian:
You must edit this file: /$ sudo vi /etc/hosts
Here you put the ip and next to the name with which you want to access.
I leave the source where I got the information from. Source