Please follow the documentation at open5gs.org!
Install MongoDB 4.4 since new version of MongoDB is not compatible with Ubuntu 22.04
# wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -OK
# echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
# apt update
# apt install mongodb-org
Ubuntu makes it easy to install Open5GS as shown below. It is enough to install from open5gs repository without build
# add-apt-repository ppa:open5gs/latest
# apt update
# apt install open5gs