FreeBSD changing pkg_add package ftp site location
pkg_add is a utility for installing software package distributions. It works like Linux apt-get command. It can download package from freebsd ftp site with the remote fetching feature. This will determine the appropriate objformat and release and then fetch and install the package. You can use following syntax:
pkg_add -v -r {package-name}
For example, you can install vim package:
# pkg_add -v -r vim
By default it downloads, the package from ftp.freebsd.org if this site is too busy then you need to use other ftp site location. You can define the environment variable PACKAGEROOT specifies an alternate location for pkg_add to fetch from. The fetch URL is built using this environment variable and the automatic directory logic that pkg_add uses when the -r option is used. For example:
# export PACKAGEROOT=ftp://ftp3.FreeBSD.org # pkg_add -v -r vim
You can select FreeBSD ftp mirror sites list. At the writing of this HONG KONG is nearest mirror for me so I will use ftp://ftp.hk.freebsd.org/
# export PACKAGEROOT=ftp://ftp.hk.freebsd.org # pkg_add -v -r zip
Besides environment variable PACKAGESITE specifies an alternate location for
pkg_add to fetch from. By default, ftp server uses directory path /pub/FreeBSD/ports/i386/packages-VERSION-release/Latest/. This variable subverts the automatic directory logic that pkg_add uses when the -r option is used. Thus it should be a complete URL to the remote package file(s).
Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
You may also be interested in other helpful articles:
- Howto: FreeBSD, OpenBSD, and NetBSD package management
- Openbsd install or add binary software package howto
- FreeBSD and Linux changing Desktop Environments/login manager
- FreeBSD keep ports collection up to date in two easy steps
- Solaris > Add / Install new software packages
Discussion on This Article:
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!


I’ve found that portupgrade suite of tools is a nice alternative to pkg_add, etc… A good starting point is HERE
Well that method is bit old, it better to use portsnap or cvsup-without-gui. Both are easy for newbie, IMPO