Install PHP on DragonFly BSD

PHP is my another concern when I study an OS. Since many project we did in the past use PHP heavily.  PHP 5.2 is another ‘can’t move on’ requirement for many project of us and available in check list.

DragonFly BSD dports also offer PHP same as I expect :

Checking available PHP version in dports

# whereis php52
php52: /usr/dports/lang/php52
dflybsd# cd /usr/dports/lang && ls -l | grep php
drwxr-xr-x  1 root  wheel  0 Jan 16 13:34 php-mode.el
drwxr-xr-x  1 root  wheel  0 Jan 16 13:34 php5
drwxr-xr-x  1 root  wheel  0 Jan 16 13:34 php5-extensions
drwxr-xr-x  1 root  wheel  0 Jan 16 13:34 php52
drwxr-xr-x  1 root  wheel  0 Jan 16 13:34 php52-extensions
drwxr-xr-x  1 root  wheel  0 Jan 16 13:34 php53
drwxr-xr-x  1 root  wheel  0 Jan 16 13:34 php53-extensions
drwxr-xr-x  1 root  wheel  0 Jan 16 13:34 php55
drwxr-xr-x  1 root  wheel  0 Jan 16 13:34 php55-extensions
drwxr-xr-x  1 root  wheel  0 Jan 16 13:34 php_doc

Nice. In general dports offer PHP  (in time of writing) :

  • PHP 5.4 : located in PHP5 (version 5.4.23)
  • PHP 5.3 (version 5.3.28)
  • PHP 5.5 (version 5.5.7)
  • PHP 5.2 (version 5.2.17)

Install PHP as Apache Module on DragonFly BSD

As I already install Apache MPM Worker previously I want to add PHP capability to web server as module.

I choose PHP 5.2

# cd /usr/dports/lang/php52 && make install

install_apache52_on_dragonflybsd

After installation completed.

Tell Apache about new PHP Module

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

Find php by press CTRL+y

Make sure there is line

LoadModule php5_module        libexec/apache22/libphp5.so

scroll down

Find dir_module and add index.php

<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>

scroll down

<IfModule mime_module>
#
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
TypesConfig etc/apache22/mime.types

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

save httpd.conf file

 

Restart Apache

# /usr/local/etc/rc.d/apache22 restart

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

put these lines :

<?php
phpinfo();
?>

save.

Testing

Open lynx browser

# lynx localhost/info.php

You’ll see

PHP Version 5.2.17

System DragonFly dflybsd.rasyid.net 3.6-RELEASE DragonFly v3.6.0-RELEASE #10: S i386
Build Date Jan 17 2014 11:27:34
Configure Command ‘./configure’ ‘–with-layout=GNU’ ‘–with-config-file-scan-dir=/usr/local/etc/php’ ‘–disable-all’ ‘–enable-libxml’
‘–with-libxml-dir=/usr/local’ ‘–enable-reflection’ ‘–program-prefix=’ ‘–disable-cgi’ ‘–with-apxs2=/usr/local/sbin/apxs’
‘–with-regex=php’ ‘–with-zend-vm=CALL’ ‘–disable-ipv6′ ‘–prefix=/usr/local’ ‘–mandir=/usr/local/man’ ‘–infodir=/usr/local/info/’
‘–build=i386-dports-dragonfly3.6′
Server API Apache 2.0 Handler
Virtual Directory Support enabled
Configuration File (php.ini) Path /usr/local/etc
Loaded Configuration File (none)
Scan this dir for additional .ini files /usr/local/etc/php
additional .ini files parsed (none)
PHP API 20041225
PHP Extension 20060613
Zend Extension 220060519
Debug Build no
Thread Safety enabled
Zend Memory Manager enabled
IPv6 Support disabled
Registered PHP Streams php, file, data, http, ftp
Registered Stream Socket Transports tcp, udp, unix, udg
Registered Stream Filters string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed
Suhosin logo This server is protected with the Suhosin Patch 0.9.7
Copyright (c) 2006 Hardened-PHP Project
Zend logo This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies