tomclegg.net


Diary
Examples
    256-router
    adzap
    apache-double-reverse
    cacti-adodb-php4
    debian-quota
    diskonmodule
    dollarsperbyte
    dynip
    ezmlm-linux
    fbsdhabits
    freebsdclone
    macbook-quantal-sound
    maildirpop3d-awfulhak
    mandy
    md
    mrtg
    net-snmp
    nodefaultroute
    oracle9i
    oracle9i-bsd5
    oracle9i-client
    oracle9i-nat
    php-cgi
  >php-commandline<
    php-image
    php-kics
    php-mini_httpd
    pinouts
    pizzaperdollar
    plesk-symlink-php
    pxe
    qmail-linux
    qmail-qfilter
    racoon-sonicwall
    redundant-vpn
    rewriterule
    seahorse-workaround
    setting-locale-failed
    smalldog
    snmpv3-cacti
    spamassassin
    squid-tproxy
    supfile
    suse73
    svc-nmbd
    svc-smbd
    svc-smtpd
    switch-virtualbox-virsh
    toyotastereo
    vm
    vn-file
    wmp-invalid
    xcode-remote-install
    xen-eth0-renamed
    xen-monowall
    xen3-ubuntu-dapper
    zz-update-grub-fail
Hire Tom
Mostly Mozart
Patches
School
Scrapbook
Software
Telephones




colocation
comments
davidireland
edsgranola
faq
funsites
goodlooking
goodmovies
google-earth-saucy-amd64
houserules
liberating
resume
resume2
scratch
shopping
snacks
todo
university
warisbogus

Installing PHP as a commandline interpreter
Posted January 23, 2006

It can be nice to have mod_php4 as well as a command line interpreter for doing #!/usr/local/bin/php stuff.

Installing both with the ports collection is a pain, so let's install the command line version separately in /usr/local/php-cli/.

Make (or choose) a user to build the PHP package. Let's call it USER. This prevents the installer from accidentally installing anything outside of /usr/local/php-cli (for example, another working PHP installation in /usr/local). It isn't necessary in this case -- the PHP installer does a good job -- but it's cheap insurance.

As root:

mkdir /usr/local/php-cli
chown USER:USER /usr/local/php-cli

As USER:

cd /tmp
tar xyf /usr/ports/distfiles/php-4.4.2.tar.bz2
cd php-4.4.2
./configure --prefix=/usr/local/php-cli --disable-cgi
make install

As root:

chown -R root:wheel /usr/local/php-cli

As any user:

echo '<? echo "ok\n"; ?>' | /usr/local/php-cli/bin/php

echo >/tmp/testphp '#!/usr/local/php-cli/bin/php'
echo >>/tmp/testphp '<? echo "ok\n"; ?>'
chmod +x /tmp/testphp
/tmp/testphp