How do I install ports in FreeBSD operating systems using the command line options?
The FreeBSD operating systems offers Ports Collection as a simple way to install various applications. Each port contains any patches necessary to make the original application source code compile and run on FreeBSD.
Get the Ports Collection
Before using ports, you must first obtain the Ports Collection /usr/ports directory. The portsnap command allows you to install ports collection over the Internet. To grab collection, enter:
# portsnap fetch
To extract the snapshot into /usr/ports, enter:
# portsnap extract
Type the above command for the first time only. If you already have a populated /usr/ports and you are just updating, run the following command instead:
# portsnap update
How Do I Search Apps / Ports?
Before you can install any Ports you need to know what you want, and what the application is called. If you know the exact name of the port, you can use the whereis command as follows:
# whereis apache22
# whereis php5
# whereis lsof
You can also use the Ports Collection's built-in search mechanism. To use the search feature, you will need to be in the /usr/ports directory. Once in that directory, run make search name=program-name where program-name is the name of the program you want to find. For example, if you were looking for apache, enter:
# cd /usr/ports
# make search name=apache
The following will perform searches for port names, comments, descriptions and dependencies and can be used to find ports which relate to a particular subject if you do not know the name of the program you are looking for.
# cd /usr/ports
# make search key=string
# make search key=php5
How Do I Install the Port Called apache22?
To install the Apache22 port, enter:
# cd /usr/ports/www/apache22/
# make install clean
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 3 comments… read them below or add one }
The output of the make search key=whatever can be quite overwhelming.
To crop it a bit use quicksearch instead of search.
Getting the ports collection for the first time, the 3 steps (fetch, extract & update) can be combine into “portsnap fetch extract update”.
To search ports you can use “psearch”, which will give a short summary next to the loation.
You’ll have to install first from ports: