1. Choose the loader
Mods are made for a specific loader and Minecraft version. Fabric is lightweight, updates quickly and is popular for performance and vanilla-plus mods. NeoForge is where most big content mods and kitchen-sink modpacks live on recent versions. Forge remains the loader for older versions such as 1.12.2 and 1.20.1. Pick the loader your must-have mods use.
2. Install the server
For Fabric, the Fabric server launcher sets everything up from one jar. For NeoForge and Forge, download the installer, run it with the --installServer option in an empty folder, and start the server with the run.sh or run.bat script it creates. Memory for NeoForge and Forge goes in user_jvm_args.txt.
Start once, accept the EULA in eula.txt, and stop the server.
3. Add the mods
Put the mod jars in the mods folder. Include each mod's dependencies, such as Fabric API for most Fabric mods, or a library mod listed on the download page. Leave out client-only mods such as shaders, minimaps that are marked client side, and performance mods like Sodium, which crash a dedicated server.
4. Match the players
Every player needs the same loader version and the same content mods. The simplest way is a modpack: publish your mod list as a pack, or use an existing pack and install its server files. Version mismatches are the cause of most "mod rejections" errors.
5. Size the server
Modded servers need more memory than vanilla even before anyone joins. A handful of mods runs in 3 to 4 GB, a mid-sized pack wants 6 to 8 GB, and large packs often need 10 GB or more. Pre-generate terrain, because modded world generation is slow.