In any version 4 and above that that it will work.
Login from root or superuser user in linux.
Go to /etc/yum.repos.d directory where all repository file are available.
# cd /etc/yum.repos.d
Create a new file having extension .repo
# vi /etc/yum.repo.d/my_linux_yum.repo
Inside vi or vim editor write :
[Server] <—— This name of directory where you keep your packages.
name = my_linux_yum <—- Any name as per your convenience.
baseurl=file:///home/user/Server <—-Complete path of the dir where package are placed.
gpgcheck = 0
:wq <— Save and quit
After that install package from your rpm directory having name createrep<tab> by below command.
#rpm -ivh createrepo<tab>
Above command will install the create repo package.
After that create you own repository by run below command.
# createrepo -v /home/user/Server
Now your yum is configured successfully, you can install packages.
#yum install java -y
#yum install c++* -y
#yum install python* -y