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.
Depends on the OS of the server, for example
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