tomclegg.net |
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 |