I’d rather run nginx and PHP5-FPM on my FreeBSD machine (to server Ampache). I’m not sure if this is possible, but I figured it’s worth a try. The idea is to use less memory and speed things up. apparently, when you use mod_php in Apache, it means that Apache loads php for every request. It’s apparently better to use FastCGI with Apache. In this case, I’d like to replace Apache with NginX, for which I need the FPM (FastCGI process manager) patch of PHP.
There’s a FreeBSD port, but it’s not in the official FreeBSD ports collection.
> cd /usr/ports/lang
> sudo wget http://php-fpm.org/downloads/freebsd-port/php-5.2.10-fpm-0.5.13.tar.gz
> sudo tar zxvf php-5.2.10-fpm-0.5.13.tar.gz
x php5-fpm/
x php5-fpm/files/
x php5-fpm/Makefile
x php5-fpm/distinfo
x php5-fpm/pkg-descr
x php5-fpm/pkg-plist
x php5-fpm/files/php-fpm.sh.in
x php5-fpm/files/patch-scripts::phpize.in
x php5-fpm/files/patch-TSRM_threads.m4
x php5-fpm/files/patch-Zend::zend.h
x php5-fpm/files/patch-Zend_zend_list.c
x php5-fpm/files/patch-Zend_zend_list.h
x php5-fpm/files/patch-ext_standard_array.c
x php5-fpm/files/patch-ext_standard_basic_functions.c
x php5-fpm/files/patch-ext_standard_dns.h
x php5-fpm/files/patch-ext_standard_image.c
x php5-fpm/files/patch-php.ini-dist
x php5-fpm/files/patch-php.ini-recommended
x php5-fpm/files/patch-main::php_config.h.in
x php5-fpm/files/patch-main_SAPI.c
x php5-fpm/files/patch-acinclude.m4
x php5-fpm/files/patch-configure.in
> cd php-fpm/
> sudo make deinstall
I selected the following options:
1 |
<span style="font-family: Courier">┌────────────────────────────────────────────────────────────────────┐ </span> |
1 |
<span style="font-family: Courier">│ Options for php5-fpm 5.2.10 │ </span> |
1 |
<span style="font-family: Courier">│ ┌────────────────────────────────────────────────────────────────┐ │ </span> |
1 |
<span style="font-family: Courier">│ │[X] CLI Build CLI version │ │ </span> |
1 |
<span style="font-family: Courier">│ │[ ] DEBUG Enable debug │ │ </span> |
1 |
<span style="font-family: Courier">│ │[X] SUHOSIN Enable Suhosin protection system (not for jails) │ │ </span> |
1 |
<span style="font-family: Courier">│ │[X] MULTIBYTE Enable zend multibyte support │ │ </span> |
1 |
<span style="font-family: Courier">│ │[X] IPV6 Enable ipv6 support │ │ </span> |
1 |
<span style="font-family: Courier">│ │[X] MAILHEAD Enable mail header patch │ │ </span> |
1 |
<span style="font-family: Courier">│ │[X] PATHINFO Enable path-info-check support │ │ </span> |
1 |
<span style="font-family: Courier">│ │ │ │ </span> |
1 |
<span style="font-family: Courier">│ │ │ │ </span> |
1 |
<span style="font-family: Courier">│ │ │ │ </span> |
1 |
<span style="font-family: Courier">│ │ │ │ </span> |
1 |
<span style="font-family: Courier">│ │ │ │ </span> |
1 |
<span style="font-family: Courier">│ │ │ │ </span> |
1 |
<span style="font-family: Courier">│ │ │ │ </span> |
1 |
<span style="font-family: Courier">│ │ │ │ </span> |
1 |
<span style="font-family: Courier">├─└────────────────────────────────────────────────────────────────┘─┤ </span> |
1 |
<span style="font-family: Courier">│ [ OK ] Cancel │ </span> |
1 |
<span style="font-family: Courier">└────────────────────────────────────────────────────────────────────┘</span> |
I’m not sure what zend multibyte nor what mail header patch are, but I figured it can’t hurt much to get them.
I got a bunch of warnings that look like
ext/pdo_pgsql/config.m4:108: warning: AC_CACHE_VAL(pdo_inc_path, …): suspicious cache-id, must contain _cv_ to be cached
ext/pdo_pgsql/config.m4:108: the top level
I ignored them (for now).
After that was done, I deinstall’ed my previous php5:
cd ../php5
sudo make deinstall
===> Deinstalling for lang/php5
===> Deinstalling php5-5.3.2
pkg_delete: package ‘php5-5.3.2′ is required by these other packages
and may not be deinstalled (but I’ll delete it anyway):
php5-mysql-5.3.2
php5-session-5.3.2
php5-iconv-5.3.2
ampache-3.5.4
php5-exif-5.3.2
pecl-fileinfo-1.0.4
php5-filter-5.3.2
php5-gd-5.3.2
php5-hash-5.3.2
php5-imap-5.3.2
php5-json-5.3.2
php5-mbstring-5.3.2
php5-mcrypt-5.3.2
php5-openssl-5.3.2
php5-pdo-5.3.2
php5-pdo_sqlite-5.3.2
php5-posix-5.3.2
php5-simplexml-5.3.2
php5-sqlite-5.3.2
php5-tokenizer-5.3.2
php5-xml-5.3.2
php5-xmlreader-5.3.2
php5-xmlwriter-5.3.2
php5-extensions-1.4
php5-zlib-5.3.2
[preparing module `php5’ in /usr/local/etc/apache22/httpd.conf]
I then went back and install’ed php with fpm:
> cd php5-fpm
> sudo make install
Unfortunately, a php-cgi –v
failed with:
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/bz2.so’ – Cannot open “/usr/local/lib/php/20060613/bz2.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/ctype.so’ – Cannot open “/usr/local/lib/php/20060613/ctype.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/dom.so’ – Cannot open “/usr/local/lib/php/20060613/dom.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/mysql.so’ – Cannot open “/usr/local/lib/php/20060613/mysql.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/session.so’ – Cannot open “/usr/local/lib/php/20060613/session.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/iconv.so’ – Cannot open “/usr/local/lib/php/20060613/iconv.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/exif.so’ – Cannot open “/usr/local/lib/php/20060613/exif.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/fileinfo.so’ – Cannot open “/usr/local/lib/php/20060613/fileinfo.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/filter.so’ – Cannot open “/usr/local/lib/php/20060613/filter.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/gd.so’ – Cannot open “/usr/local/lib/php/20060613/gd.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/hash.so’ – Cannot open “/usr/local/lib/php/20060613/hash.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/imap.so’ – Cannot open “/usr/local/lib/php/20060613/imap.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/json.so’ – Cannot open “/usr/local/lib/php/20060613/json.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/mbstring.so’ – Cannot open “/usr/local/lib/php/20060613/mbstring.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/mcrypt.so’ – Cannot open “/usr/local/lib/php/20060613/mcrypt.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/openssl.so’ – Cannot open “/usr/local/lib/php/20060613/openssl.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/pdo.so’ – Cannot open “/usr/local/lib/php/20060613/pdo.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/pdo_sqlite.so’ – Cannot open “/usr/local/lib/php/20060613/pdo_sqlite.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/posix.so’ – Cannot open “/usr/local/lib/php/20060613/posix.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/simplexml.so’ – Cannot open “/usr/local/lib/php/20060613/simplexml.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/sqlite.so’ – Cannot open “/usr/local/lib/php/20060613/sqlite.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/tokenizer.so’ – Cannot open “/usr/local/lib/php/20060613/tokenizer.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/xml.so’ – Cannot open “/usr/local/lib/php/20060613/xml.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/xmlreader.so’ – Cannot open “/usr/local/lib/php/20060613/xmlreader.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/xmlwriter.so’ – Cannot open “/usr/local/lib/php/20060613/xmlwriter.so” in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20060613/zlib.so’ – Cannot open “/usr/local/lib/php/20060613/zlib.so” in Unknown on line 0
This is because the version of php5-extensions was built with php 5.3. So, I had to deinstall and reinstall it. Unfortunately, the php5-extensions port somehow got unsynchronized from the individual extensions. So, I had to manually deinstall and reinstall. In this case, I used pkg_delete
to deinstall:
> cat php5_deinstall.sh
sudo pkg_delete php5-bz2-5.3.2
sudo pkg_delete php5-ctype-5.3.2
sudo pkg_delete php5-dom-5.3.2
sudo pkg_delete php5-exif-5.3.2
sudo pkg_delete php5-filter-5.3.2
# don’t delete this! sudo pkg_delete php5-fpm-5.2.10
sudo pkg_delete php5-gd-5.3.2
sudo pkg_delete php5-gettext-5.3.2
sudo pkg_delete php5-hash-5.3.2
sudo pkg_delete php5-iconv-5.3.2
sudo pkg_delete php5-imap-5.3.2
sudo pkg_delete php5-json-5.3.2
sudo pkg_delete php5-mbstring-5.3.2
sudo pkg_delete php5-mcrypt-5.3.2
sudo pkg_delete php5-mysql-5.3.2
sudo pkg_delete php5-openssl-5.3.2
sudo pkg_delete php5-pdo-5.3.2
sudo pkg_delete php5-pdo_sqlite-5.3.2
sudo pkg_delete php5-posix-5.3.2
sudo pkg_delete php5-session-5.3.2
sudo pkg_delete php5-simplexml-5.3.2
sudo pkg_delete php5-sqlite-5.3.2
sudo pkg_delete php5-tokenizer-5.3.2
sudo pkg_delete php5-xml-5.3.2
sudo pkg_delete php5-xmlreader-5.3.2
sudo pkg_delete php5-xmlwriter-5.3.2
sudo pkg_delete php5-zlib-5.3.2
Curiously, php52-extensions
didn’t work. Instead, I got:
> cd php52-extensions/
> sudo make install clean
Password:
===> php52-extensions-1.3 cannot install: doesn’t work with PHP version : 5 (Doesn’t support PHP 4 5).
*** Error code 1
Stop in /usr/ports/lang/php52-extensions.
Somehow, php5-extensions seems to be working. I’m crossing my fingers that I’m not mixing versions of php (5.2 vs 5.3). I’ll keep you posted when the build is finished…
… Nope, didn’t work. I’ll probably go back to plain old PHP5:
/usr/ports/textproc/php5-dom/work/php-5.3.2/ext/dom/attr.c: In function ‘zim_domattr___construct’:
/usr/ports/textproc/php5-dom/work/php-5.3.2/ext/dom/attr.c:65: error: ‘zend_error_handling’ undeclared (first use in this function)
/usr/ports/textproc/php5-dom/work/php-5.3.2/ext/dom/attr.c:65: error: (Each undeclared identifier is reported only once
/usr/ports/textproc/php5-dom/work/php-5.3.2/ext/dom/attr.c:65: error: for each function it appears in.)
/usr/ports/textproc/php5-dom/work/php-5.3.2/ext/dom/attr.c:65: error: expected ‘;’ before ‘error_handling’
/usr/ports/textproc/php5-dom/work/php-5.3.2/ext/dom/attr.c:67: error: ‘error_handling’ undeclared (first use in this function)
*** Error code 1
1 error
*** Error code 1
Stop in /usr/ports/textproc/php5-dom.
*** Error code 1
Stop in /usr/ports/lang/php5-extensions.
*** Error code 1
Stop in /usr/ports/lang/php5-extensions.
… Or, I’ll install using the individual ports for each of the php52 extensions.
One Comment