How to install and configure MacPorts

Install the latest version of MacPorts for your version of OS X (download and run the .pkg).
 
After running, open up the Terminal and copy and paste the following into it:
echo export PATH=/opt/local/bin:/opt/local/sbin:\$PATH$'\n'export MANPATH=/opt/local/man:\$MANPATH | sudo tee -a /etc/profile
 
The Terminal will ask for your password so enter it and press enter. If you ran the command correctly, the Terminal should respond with:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/man:$MANPATH

 
If you didn't get that response, it might be because the Admin account doesn't have a password set. Setting a password is required.
 
Next, run this command:
$ if [ `sysctl -n hw.cpu64bit_capable` -eq 1 ] ; then echo "+universal" | sudo tee -a /opt/local/etc/macports/variants.conf; else echo "not 64bit capable"; fi
 
On newer computers, the Terminal will respond with "+universal". If you have an older computer, the Terminal will respond with "not 64bit capable". Either way is fine, but MacPorts needs to know one way or the other, and that command should do the trick.
 
Next, install the macport you want to use (e.g. iperf):
sudo port install iperf
 
Finally, clean the install up (removing unused tarballs for instance) by typing in:
sudo port clean --all iperf
 
(of course, in this example it's iperf, but clean the macport you just installed). You may need to enter your admin password again.
 
All done. Map