To sync your Mac with iCloud Photos:
In System Preferences, make sure you are logged into the same Apple ID that the iPhone uses.
Open the library you want to sync in Photos (if it is not already open).
In Photos > Preferences > General, make sure that the text "Use as System Photo Library" in the button on the right under "Library Location" is dimmed (harder to read than "Show in Finder" in the button to its left). If it is not, click on the "Use as System Photo Library" button.
In Photos > Preferences > iCloud, make sure "iCloud Photos" is checked.
Assuming you have room for all of your photos and videos in the library, you probably want to have "Download Originals to this Mac" is checked.
Photos on the Mac should start uploading to iCloud any photos and videos in its library (attempting to avoid creating exact duplicates) to iCloud Photos along with the folder and album structure; they should then be downloaded to the other device(s). After the Photos on the Mac has finished the upload, it should start downloading any photos and videos that are in iCloud Photos but not in the Mac's Photos library. Depending on how many photos and videos you have on each device and the speed of your internet link, this might take quite a while (hours, days, even weeks).
After this initial mass upload and download, the libraries on the Mac, on the iPhone, in the cloud, and on any other devices linked to iCloud Photos with the same Apple ID should remain in sync, propagating additions, edits, and deletions as necessary.