FreeBSD:php

From Hackepedia
Jump to navigationJump to search

This will install the PHP 5 base system on your FreeBSD machine from the ports tree, and clean up everything when it's done.

# cd /usr/ports/lang/php5/ && make install distclean

often you will need a php extension installed. In order to help the various people who are stuck like I was, here is a list of possible extensions you may need/want:

               BCMATH          "bc style precision math functions" off \
               BZ2             "bzip2 library support" off \
               CALENDAR        "calendar conversion support" off \
               CTYPE           "ctype functions" on \
               CURL            "CURL support" off \
               DBA             "dba support" off \
               DBASE           "dBase library support" off \
               DOM             "DOM support" on \
               EXIF            "EXIF support" off \
               FILEINFO        "fileinfo support" off \
               FILEPRO         "filePro support" off \
               FRIBIDI         "FriBidi support" off \
               FTP             "FTP support" off \
               GD              "GD library support" off \
               GETTEXT         "gettext library support" off \
               GMP             "GNU MP support" off \
               HASH            "HASH Message Digest Framework" on \
               ICONV           "iconv support" on \
               IMAGICK         "ImageMagick support" off \
               IMAP            "IMAP support" off \
               INTERBASE       "Interbase 6 database support (Firebird)" off \
               LDAP            "OpenLDAP support" off \
               MBSTRING        "multibyte string support" off \
               MCRYPT          "Encryption support" off \
               MHASH           "Crypto-hashing support" off \
               MING            "ming shockwave flash support" off \
               MSSQL           "MS-SQL database support" off \
               MYSQL           "MySQL database support" off \
               MYSQLI          "MySQLi database support" off \
               NCURSES         "ncurses support (CLI only)" off \
               ODBC            "unixODBC support" off \
               OPENSSL         "OpenSSL support" off \
               PANDA           "panda support" off \
               PCNTL           "pcntl support (CLI only)" off \
               PCRE            "Perl Compatible Regular Expression support" on \
               PDF             "PDFlib support (implies GD)" off \
               PDO             "PHP Data Objects Interface (PDO)" on \
               PGSQL           "PostgreSQL database support" off \
               POSIX           "POSIX-like functions" on \
               PSPELL          "pspell support" off \
               READLINE        "readline support (CLI only)" off \
               RECODE          "recode support" off \
               SESSION         "session support" on \
               SHMOP           "shmop support" off \
               SIMPLEXML       "simplexml support" on \
               SNMP            "SNMP support" off \
               SOAP            "SOAP support" off \
               SOCKETS         "sockets support" off \
               SQLITE          "sqlite support" on \
               SYBASE_CT       "Sybase database support" off \
               SYSVMSG         "System V message support" off \
               SYSVSEM         "System V semaphore support" off \
               SYSVSHM         "System V shared memory support" off \
               TIDY            "TIDY support" off \
               TOKENIZER       "tokenizer support" on \
               WDDX            "WDDX support (implies XML)" off \
               XML             "XML support" on \
               XMLREADER       "XMLReader support" on \
               XMLRPC          "XMLRPC-EPI support" off \
               XMLWRITER       "XMLWriter support" on \
               XSL             "XSL support (Implies DOM)" off \
               YAZ             "YAZ support (ANSI/NISO Z39.50)" off \
               ZIP             "ZIP support" off \
               ZLIB            "ZLIB support" off

Initially my searches online led me to know I needed the session extension for php. As it wasn't intuitive to me, I manually added "--enable-session" to the Makefile in /usr/ports/lang/php5/. I was told this is the wrong approach, and it could affect me later. So there are two approaches from here. One way to find the two approaches:

# ( cd /usr/ports && make search key=pcre | grep Path: | grep php5 )
Path:   /usr/ports/devel/php5-pcre
Path:   /usr/ports/lang/php5-extensions
Path:   /usr/ports/www/horde-php5

so if I just want to install a single extension, it's probably found in /usr/ports/devel/php5-pcre or if I want to install several, I can install each individually, or go into the php extensions meta port

# cd /usr/ports/lang/php5-extensions && make config

will give me an ncurses based window to go through and pick the extensions I want. After that I can do

# make install distclean

as long as I'm still in the usr/ports/lang/php5-extensions directory.


If you find that you've forgotten to install an extension or decide to add one (or more) later, the process is a little different from above. To get the ncurses window to appear again enter the 'make config' command.

# make config

This will allow you to choose additional extensions (the ncurses screen will already have your previously installed extensions selected). Select the additional extension(s) that you want to add.

Enter the following commands to install the additional extensions:

# make uninstall
# make reinstall

To confirm what extensions are compiled into php, enter this at the command line:

# php -m

The output of this command will show the compiled-in extensions in alphabetical order.


Errors

Fatal error: Call to undefined function preg_match() in

This means you will want to install the pcre extension.