Skip to content
Chun-Sheng, Li edited this page Dec 27, 2022 · 57 revisions

You should not see this, please check if bashrc is sourced in your shell.

If you saw this, please run init command to initialize the shell script file:

phpbrew init

And to load the phpbrew function, please add the line below to your .zshrc or .bashrc, if the .bashrc does not exist, please try .bash_profile or .profile instead:

[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc

Close your terminal and re-open a new one, run which phpbrew and see if it dumps the function code for you. If it does, then it's correct.

I can't install extension, why?

If you see your extension installation failed, you should add --debug flag to see the debug message and see what makes it failed. Normally the failure is caused by missing configure options or wrong paths.

phpbrew --debug ext install gd

You can also check the configure options of the extension, by running:

phpbrew ext show gd
                Name: gd
    Source Directory: /Users/c9s/.phpbrew/build/php-5.5.17/ext/gd
              Config: /Users/c9s/.phpbrew/build/php-5.5.17/ext/gd/config.m4
            INI File: /Users/c9s/.phpbrew/php/php-5.5.17/var/db/gd.ini
           Extension: Core
                Zend: no
              Loaded: yes

   Configure Options:

        --enable-gd-native-ttf           whether to enable truetype string function in GD

        --enable-gd-jis-conv             whether to enable JIS-mapped Japanese font support in GD

        --with-gd[=DIR]                  for GD support

        --with-vpx-dir[=DIR]             for the location of libvpx

        --with-jpeg-dir[=DIR]            for the location of libjpeg

        --with-png-dir[=DIR]             for the location of libpng

        --with-zlib-dir[=DIR]            for the location of libz

        --with-xpm-dir[=DIR]             for the location of libXpm

        --with-freetype-dir[=DIR]        for FreeType 2

        --with-t1lib[=DIR]               for T1lib support

And add some configure options to fix your install:

phpbrew --debug ext install gd -- --with-gd=/opt/local --with-png-dir=/opt/local --with-jpeg-dir=/opt/local

Please note that --enable-gd-native-ttf is only available on platforms support X11, or you will see: fatal error: 'X11/xpm.h' file not found

Version < 5.3.22 not found

It's because museum.php.net has been down for a while, for now, you can download older versions through the mirror of National Taiwan University. To do this, just pass a --mirror [URL] option to phpbrew:

$ phpbrew install --mirror http://ftp.ntu.edu.tw/tmp/php 5.3.10

fatal error: 'ext/mysqlnd/mysqlnd.h' file not found

if you got:

In file included from ~/.phpbrew/build/php-5.6.1/ext/mysql/php_mysql.c:69:
./php_mysql_structs.h:39:10: 
#include "ext/mysqlnd/mysqlnd.h"

I guess you were running extension installer to install mysql like this:

phpbrew ext install mysql

please note that mysql extension must be compiled during the PHP installation. and here is what I recommended:

phpbrew install +pdo +mysql

can not configure with +gd

Run with +gd=shared,/usr variant, which will be expanded to --with-gd=shared,/usr, e.g.,

phpbrew install 5.4.22 +gd=shared,/usr

On Ubuntu 14.04, configure: error: freetype.h not found:

Execute the following command:

ln -s /usr/include/freetype2 /usr/include/freetype2/freetype

On Ubuntu 20.04, easy.h should be in <curl-dir>/include/curl/

If you see the following error:

checking for cURL in default path... not found

configure: error: Please reinstall the libcurl distribution -

    easy.h should be in <curl-dir>/include/curl/

You can fix it on Ubuntu with:

sudo apt-get install libcurl4-gnutls-dev
sudo ln -s /usr/include/x86_64-linux-gnu/curl /usr/local/include/curl

Related issues:

configure: error: Please reinstall the iconv library:

There is a php build system bug on Linux: https://bugs.php.net/bug.php?id=48451

Please try to configure with +iconv=shared or +iconv

 phpbrew --debug install 5.4.22 +iconv=shared

or

 phpbrew --debug install 5.4.22 +iconv

iconv: undefined reference to `libiconv_open'

https://bugs.php.net/bug.php?id=42547

https://bugs.php.net/bug.php?id=52611

install php5.3.24 and it reports "unrecognized option -export-dynamic'"

Please also add +intl variant, e.g.,

phpbrew install 5.3.12 +default +intl

Related issues:

library or header file not found

  • check if you installed the library (.a or .so)

  • check if you installed the header files (.h files)

  • print the configure options to see which directory is using, run phpbrew install with -d or --debug flag to see what's the configure options, e.g.,

      $ phpbrew -d install 5.4.22
    
  • search for the location of the required header files:

      $ locate foobar.h
    
  • search for the location of the required so files:

      $ locate foobar.so
    
  • try php-config to see the configure options of the current running php, and compare the options with your debug message, then adjust your variant to match the options.

    • If you still can not resolve the problem, then please fire an issue with your phpbrew version, OS, configure options.

pcre.h is not found when installing extension

Make sure that you've installed pcre package, you can run pkg-config to find out the include path:

pkg-config --libs --cflags libpcre

Then, set the include directory in the CFLAGS environment variable to install extension:

CFLAGS="-I/opt/local/include" phpbrew ext install pecl_HTTP

PHP Fatal error: require(): Failed opening required 'phar://phpbrew.phar/Universal/ClassLoader/SplClassLoader.php'

It seems this is caused by the Ioncube extension. Make sure that the ioncube extension is disabled. On centos, edit /etc/php.d/ioncube-loader.ini and comment the line out.

fatal error: ft2build.h: No such file or directory

If you see this:

ext/gd/libgd/gdft.c:64:22: fatal error: ft2build.h: No such file or directory

It means you're missing freetype library, please install the freetype library and the header files, and append --with-freetype-dir={prefix} to the extension command.

For me, my ftbuild.h is located at /opt/local/include/freetype2/ft2build.h, therefore I run:

phpbrew --debug ext install gd -- --with-freetype-dir=/opt/local

You can run phpbrew ext show gd to see the detail of the options.

error: dereferencing pointer to incomplete type

On Ubuntu 14.04 trying to compile PHP versions of 5.4.0 <= PHP <= 5.4.6 or 5.3.1 <= PHP <= 5.3.16 you may receive this error:

/path/to/home/.phpbrew/build/php-{version}/ext/dom/node.c: In function ‘dom_canonicalization’:
/path/to/home/.phpbrew/build/php-{version}/ext/dom/node.c:1898:21: error: dereferencing pointer to incomplete type
    ret = buf->buffer->use;
    ....

This occurs when libxml2 >= 2.9.0 is installed. Patching the extraced sources will resolve this issue:

$ cd ~/.phpbrew/build/php-{version}/
$ curl -s https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt | patch -p0
patching file ext/dom/node.c
patching file ext/dom/documenttype.c
patching file ext/simplexml/simplexml.c

Related Issue:

configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.

If you got this:

checking for location of ICU headers and libraries... not found
configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.

Your icu4c is not setup properly, you need to run:

# For macOS
brew install intltool icu4c
brew link icu4c gettext --force

If it ensures that the related libicu-dev package is installed in Debian/Ubuntu, it should miss the icu-config command.

The solution is available here.

Using the following command to resolve this issue:

wget https://gist.githubusercontent.com/jasny/e91f4e2d386e91e6de5cf581795e9408/raw/16e2c42136eb3f214222c80d492e71942b77f174/icu-config
chmod +x icu-config
sudo mv icu-config /usr/bin

error: name lookup timed out

This error may appear when you try to run known, install, update or download commands. It refers to the network layer's latency during connection to the server or DNS lookup.

Try to set a bigger timeout by CONNECT_TIMEOUT environment variable or --connect-timeout commands option.

$ export CONNECT_TIMEOUT=30
$ phpbrew known

or

$ phpbrew known --connect-timeout=30

configure: error: Please reinstall readline - I cannot find readline.h

Fedora, CentOS:

yum install readline-devel

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

Fedora, CentOS:

yum install mcrypt libmcrypt-devel

configure: error: Unable to find gd.h anywhere under /usr

Fedora, CentOS:

yum install gd gd-devel

My apache2 doesn't use the installed php? what's wrong?

Keywords: phpinfo, apache2, extension, module, apxs

It means your apache2 loads the wrong (or system built-in) php. you have to modify your apache config to load the desired php module. please be sure to install your php with +apxs=... variant, phpbrew should enable your apache2 php module automatically.

If this doesn't solve your issue, please investigate by the following steps:

php -i | grep apxs
grep -r 'LoadModule php5_module' /etc/apache2
ls -l /usr/lib/apache2/modules

Related issues:

+apxs2= doesn't work, the php apache2 module isn't compiled

Error messages:

checking for Apache 2.0 handler-module support via DSO through APXS... [Sat Jan 03 15:14:03.368521 2015] [core:warn] [pid 10151] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Sat Jan 03 15:14:03.368570 2015] [core:warn] [pid 10151] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Sat Jan 03 15:14:03.368578 2015] [core:warn] [pid 10151] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Sat Jan 03 15:14:03.368580 2015] [core:warn] [pid 10151] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Sat Jan 03 15:14:03.368588 2015] [core:warn] [pid 10151] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf

The apache2 on Ubuntu Linux requires you to load the environment variables before accessing the configurations from the apxs2 binary. Hence, you need to run the command below to ensure apxs2 can read your apache2 config file:

source /etc/apache2/envvars
apache2 -V
phpbrew --debug install 5.5 +apxs2=$(which apxs2)

Can't build php 5.2, what's wrong?

Since php 5.2 should be dead already. If you still want/need to install php 5.2 (sorry for you) it won't be easy because most distro's build toolchains will offer trouble.

https://github.com/phpbrew/phpbrew/issues/492#issuecomment-111742848

I cannot install extension X with PHP 7

When installing extensions like memcached or redis with php 7.x, compilation fails if with

./common.h:3:10: fatal error: 'ext/standard/php_smart_str.h' file not found
#include <ext/standard/php_smart_str.h>

if you use phpbrew ext install redis or phpbrew ext install memcached. Mainly, that's because the maintainers decided to keep php 7.x compatible version on a branch different than master. This can be the problem with other extensions as well.

You can install them by pointing extension installer to particular repository and branch like: phpbrew ext install <repository_address> <branch_name>

As for the time of writing this, redis or memcached can be installed with:

  • phpbrew ext install https://github.com/phpredis/phpredis php7
  • phpbrew ext install https://github.com/php-memcached-dev/php-memcached php7 -- --disable-memcached-sasl

configure: error: Package requirements (oniguruma) were not met

The error message sometimes is Alternatively, you may set the environment variables ONIG_CFLAGS.

Since compiling the php-7.4+ version with mbstring extension, it needs to install the libonig-dev package firstly.

For Ubuntu:

sudo apt-get install libonig-dev

Compiling PHP7.4 with the OpenSSL extension error in Ubuntu 22.04

  • The issue is described here.

  • The resolved solution is as follows:

  • Compile the OpenSSL 1.1 from source

cd $HOME
wget https://www.openssl.org/source/openssl-1.1.1i.tar.gz
tar -xzf $HOME/openssl-1.1.1i.tar.gz
cd openssl-1.1.1i
./Configure --prefix=$HOME/openssl-1.1.1i/bin -fPIC -shared linux-x86_64
make -j 8 
make install
  • Set the OpenSSL1.1 path and compile the PHP 7.4.29 with PHPBrew
export PKG_CONFIG_PATH=$HOME/openssl-1.1.1i/bin/lib/pkgconfig && phpbrew --debug install 7.4 +default

Compiling the PHP with Apache2 SAPI support error about Exception: apxs binary is not executable

To compile the PHP with Apache2 SAPI support, it needs to install the Apache2 development package.

For Ubuntu:

sudo apt-get install apache2-dev

Running the phpbrew fpm start command is failed

When running the phpbrew fpm start command, it presents the following error message:

Starting php-fpm...
[30-Nov-2022 08:24:18] ERROR: [pool www] cannot get gid for group 'nobody'
[30-Nov-2022 08:24:18] ERROR: FPM initialization failed
php-fpm start failed.

It seems that the nobody group is not found and it can simply run the groupadd nobody command to resolve the issue.

Unable to compile gd for php7.2 or 7.3 in Ubuntu 20.04.1 LTS using freetype support

The current solution is described here.

PHP build failing readdir_r in the macOS 11.x

The issue and solution is described here.

It can run the export CFLAGS="-Wno-implicit-function-declaration" command to set the CFLAGS environment variables before running the phpbrew install command.

Fatal error: 'capstone/capstone.h' file not found in the macOS 11.x

The related issue is available here.

It might be happened in the macOS 11.x. To resolve the issue, it should run the brew remove capstone command to avoid using the package.