Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


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
share|improve this question

migrated from Dec 5 '10 at 7:12

This question came from our site for professional and enthusiast programmers.

Why didn't you use apt-get? – Tim McNamara Dec 4 '10 at 20:10
@Tim - Because it's not PHP 5.3.3 – TiuTalk Dec 4 '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 4 '10 at 20:11
@ajreal - – TiuTalk Dec 4 '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 4 '10 at 20:16
up vote 4 down vote accepted

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
share|improve this answer
Solved it! thanks! :) – TiuTalk Dec 4 '10 at 20:58
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 4 '10 at 21:06

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.

share|improve this answer
Only one file: /tmp/zend_debug/session8635259034721613818.tmp/php.ini – TiuTalk Dec 4 '10 at 20:12
+1 i like cli :) – tawfekov Dec 4 '10 at 20:19

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 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 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.

share|improve this answer
Is there a way to uninstall my compiled PHP? – TiuTalk Dec 4 '10 at 21:39
not really. When you build and install something from source, you can use 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 4 '10 at 22:55
you might try installing your "compiled version" again -- but this time use 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 4 '10 at 22:58

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

share|improve this answer
bash: cd: /etc/php5: File or directory not found – TiuTalk Dec 4 '10 at 20:09

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,

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
share|improve this answer
If i try to install php5-cli package it'll install PHP5 too (not using the PHP 5.3.3 that I've compiled) – TiuTalk Dec 4 '10 at 20:11
you have lost time compling it while you can download it as easy as apt-get – tawfekov Dec 4 '10 at 20:16
yup, and try php -n --info – ajreal Dec 4 '10 at 20:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.