3

Hiho!

Today I leave my comfort zone and want to edit my php.ini file and... guest what? It doesn't exist!

$ php --ini

Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File:         (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

Loaded Configuration File: (none)!

What the hell? I never saw this.. Is threre a way to create or enable the PHP ini?


I compiled it myself:

$ php -v

PHP 5.3.3 (cli) (built: Dec  3 2010 16:08:11) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
Thiago Belem
  • 135
  • 1
  • 3
  • 12
  • Why didn't you use apt-get? – Tim McNamara Dec 04 '10 at 20:10
  • @Tim - Because it's not PHP 5.3.3 – Thiago Belem Dec 04 '10 at 20:10
  • @TuiTalk - Seems like you forget to put in the path where doing compilation? try `php -i|grep config -i`, in CLI, `php -n --ini` will skip the loading php.ini – ajreal Dec 04 '10 at 20:11
  • @ajreal - http://pastebin.com/pxh480YW – Thiago Belem Dec 04 '10 at 20:14
  • @TuiTalk - recompiled with option `./configure --with-config-file-path=/usr/local/lib` ... between, where is php.ini originally placed? – ajreal Dec 04 '10 at 20:16
  • @ajreal - Recompilin.. – Thiago Belem Dec 04 '10 at 20:20
  • @TuiTalk - and remember to copy any existing php.ini into /usr/local/lib , if there is none, copy the ini in the tmp folder **OR** simply just copy the ini in the tmp folder to /usr/local/lib because the default path is /usr/local/lib – ajreal Dec 04 '10 at 20:22
  • @TuiTalk: ubuntu 10.10 *does* provide [PHP 5.3.3 via apt](http://packages.ubuntu.com/maverick/php/php5-fpm). So maybe no need to build it yourself after all. See my answer below for details. – Lee Dec 04 '10 at 20:54

5 Answers5

5

Use find to find the file:

find / -name "php.ini" 2> /dev/null

2> /dev/null just hides STDERR for you, due to permissions errors.

Tim McNamara
  • 273
  • 1
  • 7
4

If you compiled PHP yourself without changing the default PHP ini path, it searches for php.ini in /usr/local/lib/. So put php.ini in /usr/local/lib/php.ini.

In the PHP package, there is a php.ini-recommended which can be copied to that location (change dir to php-5.3.3):

sudo cp php.ini-recommended /usr/local/lib/php.ini
Lekensteyn
  • 6,241
  • 6
  • 39
  • 55
  • This is the correct answer to the question as asked. But it should be pointed out that Ubuntu 10.10 (maverick) *does* include PHP 5.3.3 in the apt repository (it's the first release of Ubuntu to do so). So the OP's reason for building from source in the first place may be based on inaccurate assumptions. (see my answer below for more info). – Lee Dec 04 '10 at 21:06
3

Actually... Ubuntu 10.10 (maverick) does provide PHP 5.3.3 as part of the standard apt package system. If you install the package php-fpm you'll even get the "new" FPM built in (which I expect is the whole reason you want 5.3.3 in the first place).

check out packages.ubuntu.com for proof

That said -- if you built PHP yourself, and didn't specify any special options to configure, then --prefix defaulted to /usr/local/, and --with-config-file-path defaulted to /usr/local/lib. So php will look for /usr/local/lib/php.ini.

You can change this by setting (for example) --with-config-file-path=/usr/local/etc as an option to ./configure.


Just for completeness: on versions of Ubuntu prior to 10.10 (where php 5.3.3 is not part of the base distro), you can get binary apt-packages for php 5.3.3 via dotdeb.org. The dotdeb repos work great on Ubuntu 8.04 Hardy. On 10.04 Lucid, they still work, but you'll have to install a few other dependencies manually (which is kind of a drag). Either way, follow the instructions on the Dotdeb Instructions Page.

Lee
  • 131
  • 1
  • Is there a way to uninstall my compiled PHP? – Thiago Belem Dec 04 '10 at 21:39
  • not really. When you build and install something from source, you can use [checkinstall](https://help.ubuntu.com/community/CheckInstall) instead of plain old `make install`. That will automatically track the source package's installation, allowing you to uninstall it (with varying degrees of completeness) via dpkg at some later point in time. However, if you didn't use checkinstall when you installed it, then you're probably stuck going through an removing everything by hand. – Lee Dec 04 '10 at 22:55
  • you might try installing your "compiled version" again -- but this time use [checkinstall](https://help.ubuntu.com/community/CheckInstall) as described above. *Then* try to uninstall using `dpkg -r`, as described at the checkinstall documentation. That'll probably get you mostly there. You'll need to manually remove any files you created manually (eg. /usr/local/lib/php.ini). – Lee Dec 04 '10 at 22:58
2

From PHP5 the php.ini file in Ubuntu 10.10 or above is located here:

/etc/php5/apache2/php.ini
Putr
  • 131
  • 3
1

php.ini in ubuntu is uaually saved in /etc/php5/apache2/php.ini and you got none because you don't have phpcli installed by using this sudo apt-get install php5-cli

the out put after intalling it would be

Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File:         /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d
Additional .ini files parsed:      /etc/php5/cli/conf.d/curl.ini,
/etc/php5/cli/conf.d/gd.ini,
/etc/php5/cli/conf.d/mcrypt.ini,
/etc/php5/cli/conf.d/mysql.ini,
/etc/php5/cli/conf.d/mysqli.ini,
/etc/php5/cli/conf.d/pdo.ini,
/etc/php5/cli/conf.d/pdo_mysql.ini,
/etc/php5/cli/conf.d/pdo_sqlite.ini,
/etc/php5/cli/conf.d/sqlite.ini,
/etc/php5/cli/conf.d/sqlite3.ini,
/etc/php5/cli/conf.d/xdebug.ini,
/etc/php5/cli/conf.d/zend-framework.ini

i do have exactly php 5.3.3

php -v :

PHP 5.3.3-1ubuntu9.1 with Suhosin-Patch (cli) (built: Oct 15 2010 14:17:04) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
tawfekov
  • 195
  • 10