header pictures for dedicated hosting services

How To Install Perl/PHP5 Using the FreeBSD Ports Collection

Using the FreeBSD Ports Collection you can easily install the Apache2, Perl, and PHP 5 modules by typing “make install clean” in the proper directory and the system will automatically fetch the application source code from your local disk or using FTP. The nice thing is that the Ports Collection not only unpacks the files on your dedicated server, but also applies patches and compiles the modules. Then you just need to type “make install” and you are on your way.

Before using the ports system, you need to make sure you have the ports collection installed. You can run the following command to check:

Note: for rest of the document, “FreeBSD#” is hostname plus prompt, the rest is command we need type.

FreeBSD# ls /usr/ports

If it returns a list of directories, that means ports collection is already installed. If it's empty or it reports an error like "No such file or directory", then you need to download ports collection and unpack it on your system. We show you how to install the ports collection directly below. IF you already have ports installed then you can skip this step and move on to installing perl, PHP and Apache.


How to Install the Freebsd Ports Collection

Follow below steps to install it if it hasn't been installed:
1. Run the following command to check your FreeBSD release version and machine architeture

FreeBSD# uname -a
FreeBSD freebsd7.my.local 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Sun Feb 24 19:59:52 UTC 2008 root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386

As you can see here, this is an i386 machine running FreeBSD 7.0

So you know which ports.tgz file to download

2. download ports collection and install script:

FreeBSD# cd /tmp
FreeBSD# fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/7.1-RELEASE/ports/install.sh
FreeBSD# fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/7.1-RELEASE/ports/ports.tgz
FreeBSD# chmod a+x install.sh
FreeBSD# ./install.sh

Remember, you need to run this as root user.

After everything is downloaed and installed, you should have the ports collection installed under /usr/ports

You are now ready to begin your installation of the other applications, startign with Perl.

How to install Perl on FreeBSD Using The Ports Collection

Execute the following command to install perl:

FreeBSD# cd /usr/ports/lang/perl
FreeBSD# make install clean

The ports system will automatically downlaod all necessary files and complile and install perl.
Easy, isn't it? now we are ready to install PHP5


How to install PHP5 on FreeBSD

You can do the same procedure to install PHP5:

FreeBSD# cd /usr/ports/lang/php5
FreeBSD# make install clean

You'll then be prompted to choose some optional modules of PHP, as shown in below screen shot:

screen shot showing the PHP5 options menu with the "build apache module" selection highlighted

Use arrow key to go up and down and use SPACE key to select the module you want to install.
Then use Tab key to highlight [ OK ] then press Enter key to continue. Ports system will install PHP5 automatically.

Now you are ready to move on to the next step and install Apache for FreeBSD.



Looking for our FreeBSD Forums? We have moved them off our main page,just follow the link to our FreeBSD Forums page.

Guests Visit the FreeBSD Forums  •  Login to the FreeBSD Forums  •  Register for FREE
Custom Search

Copyright © 2009,2010,2011,2012,2013,2014,2015,2016,2017, WEBSERVER CONSUMER GUIDE

Privacy Policy

Please note:
(1) FreeBSD is a registered trademark of The FreeBSD Foundation.
(2) WEBSERVER CONSUMER GUIDE is in no way affiliated with The FreeBSD Foundation