HowTo: Install Ports in Freebsd

by on April 5, 2011 · 3 comments· LAST UPDATED April 5, 2011

in

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

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 3 comments… read them below or add one }

1 me April 6, 2011 at 5:20 am

The output of the make search key=whatever can be quite overwhelming.
To crop it a bit use quicksearch instead of search.

Reply

2 PsyberMonkey April 30, 2011 at 11:25 am

Getting the ports collection for the first time, the 3 steps (fetch, extract & update) can be combine into “portsnap fetch extract update”.

Reply

3 Makimoto July 29, 2011 at 12:01 pm

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:

cd /usr/ports/ports-mgmt/psearch; make install clean

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: