Install php 5.2.17 on FreeBSD 9.2

 Install php 5.2.17 on FreeBSD 9.2
Another server came and the requirement still same. PHP 5.2.17 is a must. I only have 2 options from the vendor; using ubuntu or freebsd.

Its 2013 and all support for php 5.2 on ubuntu server already gone. I have one option left for this job. FreeBSD. Since my last work with FreeBSD I also think FreeBSD 9.2 already throw PHP 5.2 but I’ll try it first.

Install Ports, PHP 5.2.17, Apache 2.2 and MySQL Server 5.1

# portsnap fetch

Looking up portsnap.FreeBSD.org mirrors… 7 mirrors found.
Fetching public key from ec2-ap-southeast-2.portsnap.freebsd.org… done.
Fetching snapshot tag from ec2-ap-southeast-2.portsnap.freebsd.org… done.
Fetching snapshot metadata… done.
Fetching snapshot generated at Mon Nov 25 07:07:20 WIT 2013:

# portsnap extract

Install latest supported PHP 5.2

# cd /usr/ports/lang/php52

Choose required stuff, Apache as web server.

Selection 019 Install php 5.2.17 on FreeBSD 9.2

===>   NOTICE:

This port is deprecated; you may wish to reconsider installing it:

PHP 5.2 series is strongly discouraged for new  installations, migrate now.

It is scheduled to be removed on or after 2014-03-01.

Wew. At least it work for my job now icon smile Install php 5.2.17 on FreeBSD 9.2

For apache selection, let it as is.

Selection 020 Install php 5.2.17 on FreeBSD 9.2

Install PHP Extensions

# cd /usr/ports/lang/php52-extensions && make install

choose extensions that you like. ( I pick MySQL, Curl, GD beside default options).

Tips : add WITHOUT_X11=yes to /etc/make.conf to prevent system install X11 related software.

Install MySQL Server

# cd /usr/ports/databases/mysql51-server && make install

Configuration

Add service to /etc/rc.conf :

# echo mysql_enable=YES >> /etc/rc.conf

# echo apache22_enable=YES >> /etc/rc.conf

Starting Service

# /usr/local/etc/rc.d/mysql-server start
Starting mysql.

Add php handler

# ee /usr/local/etc/apache22/httpd.conf

Make sure these lines exists :

LoadModule php5_module        libexec/apache22/libphp5.so

in load module list

DirectoryIndex index.php index.html

in IfModule dir_module

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

inside IfModule mime_module directive.

# /usr/local/etc/rc.d/apache22 start
Performing sanity check on apache22 configuration:
Syntax OK
Starting apache22.

Testing

Create php script

# ee /usr/local/www/apache22/data/info.php

put these lines :

<?php
phpinfo();
?>

save.

Open via lynx

lynx localhost/info.php

then I get

Selection 023 Install php 5.2.17 on FreeBSD 9.2

Picture source : Mysql Apache Linux PHP Mugs by Zerotees