tomclegg.net


Diary
Examples
    256-router
    adzap
    debian-quota
    diskonmodule
    dynip
    ezmlm-linux
    fbsdhabits
    freebsdclone
    maildirpop3d-awfulhak
    mandy
    md
    mrtg
    net-snmp
    oracle9i
    oracle9i-bsd5
    oracle9i-client
    oracle9i-nat
    php-cgi
  >php-commandline<
    php-image
    php-kics
    php-mini_httpd
    pinouts
    plesk-symlink-php
    pxe
    qmail-linux
    qmail-qfilter
    racoon-sonicwall
    redundant-vpn
    rewriterule
    smalldog
    spamassassin
    squid-tproxy
    supfile
    suse73
    svc-nmbd
    svc-smbd
    svc-smtpd
    toyotastereo
    vm
    vn-file
    wmp-invalid
    xcode-remote-install
    xen-eth0-renamed
    xen3-ubuntu-dapper
Hire Tom
Mostly Mozart
Patches
School
Scrapbook
Software
Telephones




colocation
comments
davidireland
edsgranola
faq
funsites
goodlooking
goodmovies
houserules
liberating
nodefaultroute
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