1

I config/make/make install php on a system where php is already installed:

 ./configure --prefix=/opt/php
 --with-config-file-path=/opt/php/etc --with-config-file-scan-dir=/opt/php/etc/php.d
 --enable-fpm --with-fpm-user=ec2-user --with-fpm-group=ec2-user --disable-debug 
 --enable-exif --with-curl --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-
 pdo-mysql=mysqlnd --with-zlib --enable-zip --enable-bcmath --enable-calendar 
 --enable-ftp --with-mhash --with-openssl --with-mcrypt --enable-mbstring --enable-
 mbregex --with-gd --with-jpeg-dir --with-png-dir

(all ok) however, when I type php --ini (inside /opt/php/bin) I get the old stuff:

> Configuration File (php.ini) Path:
> /etc Loaded Configuration File:       
> /etc/php.ini Scan for additional .ini
> files in: /etc/php.d Additional .ini
> files parsed:      /etc/php.d/apc.ini,
> /etc/php.d/curl.ini,
> /etc/php.d/fileinfo.ini,
> /etc/php.d/json.ini,
> /etc/php.d/mbstring.ini,
> /etc/php.d/phar.ini,

why / how can i fix this?

my bashrc:

if [ -d "/opt/php/bin"] && [ -d "/opt/php/sbin" ]; then PATH="$path:/opt/php/bin:/opt/php/bin"

my php-config looks ok:

Usage: ./php-config [OPTION]
Options:
  --prefix            [/opt/php]
  --includes          [-I/opt/php/include/php -I/opt/php/include/php/main -I/opt/php/include/php/TSRM -I/opt/php/include/php/Zend -I/opt/php/include/php/ext -I/opt/php/include/php/ext/date/lib]
  --ldflags           []
  --libs              [-lcrypt   -lz -lcrypt -lrt -lmcrypt -lltdl -lpng -lz -ljpeg -lcurl -lz -lrt -lm -ldl -lnsl  -lrt -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lcurl -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt ]
  --extension-dir     [/opt/php/lib/php/extensions/no-debug-non-zts-20090626]
  --include-dir       [/opt/php/include/php]
  --php-binary        [/opt/php/bin/php]
  --php-sapis         [cli fpm]
  --configure-options [--prefix=/opt/php --with-config-file-path=/opt/php/etc --with-config-file-scan-dir=/opt/php/etc/php.d --enable-fpm --with-fpm-user=ec2-user --with-fpm-group=ec2-user --disable-debug --enable-exif --with-curl --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib --enable-zip --enable-bcmath --enable-calendar --enable-ftp --with-mhash --with-openssl --with-mcrypt --enable-mbstring --enable-mbregex --with-gd --with-jpeg-dir --with-png-dir]
  --version           [5.3.5]
  --vernum            [50305]

but... myphp.ini does not, it seems my --with-config-file-path=PATH (Sets the path in which to look for php.ini, defaults to PREFIX/lib.) somehow is not working?

edelwater
  • 2,650
  • 8
  • 39
  • 67
  • 2
    Does typing `./php --ini` in `/opt/php/bin` change anything? – Felix Apr 08 '11 at 22:23
  • 1
    @Felix is probably right. `php` and `./php` are two different things. `php` takes the one in $PATH (probably /usr/bin/php) while `./php` takes the one in the cwd. – netcoder Apr 08 '11 at 22:28
  • yes... it shows another old location..... /usr/local/lib... though the time of the php is the time i build it (i changed and exported the bashrc path – edelwater Apr 08 '11 at 22:29

4 Answers4

2

In PHP request #45114, jani@php.net writes:

I added 2 ways to do this. Now you can either use both -n and -c in command line options (-n disables every ini loading, -c enables loading the specified file / from specified path) or set PHP_INI_SCAN_DIR environment variable to empty (disables scanning) or to point to some other directory.

Example:

php -n -c /conf -r'phpinfo();'

Output:

...
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /conf/php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
...
Val Kornea
  • 4,469
  • 3
  • 40
  • 41
2

Here is what I did in a similar situation :

Context: PHP loaded as an Apache module (eg DSO)

HOW in short :
shell ENV

PHP_INI_SCAN_DIR=/pathtophpini
export PHP_INI_SCAN_DIR

http.conf

# ...
# DSO Modules: PHP as an Apache module
SetEnv PHPRC /usr/pathtophpini
SetEnv PHP_INI_SCAN_DIR /usr/pathtophpini

LoadModule php5_module /pathtophpmod/libphp5.so
PHPINIDir /pathtophpini
# ...

Shell

/etc/init.d/apache2 restart   

Then I can choose the php.ini file I want to get loaded at Apache start.

hornetbzz
  • 9,188
  • 5
  • 36
  • 53
1

Try the command which -a to see which php executable is in the path.

wallyk
  • 56,922
  • 16
  • 83
  • 148
0

I now had 5.3.5. I wget-ed 5.3.6, configure, make, make install...

and the .ini settings were ok.

edelwater
  • 2,650
  • 8
  • 39
  • 67
  • 1
    Does this mean it's working now? If you change the ini location via configure after you already built it once, I think you have to do a `make clean && make` in order for it to get updated. – Matthew Apr 09 '11 at 07:55
  • its not working completely ... but I think i now have another thingie "unable to globalize" but that is out of scope for this question. Yes...... make I forgot to do make clean could be. – edelwater Apr 09 '11 at 08:10