Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using localhost to run a website locally; my problem is that I can't get the correct php.ini to load.

I have set the Directory and DocumentRoot fields in /etc/apache2/sites-available/default, and restarted the apache2 server.

But running phpinfo() in my localhost still tells me I'm loading the ini file at /etc/php5/apache2/php.ini.

Why? How can I change which php.ini file gets loaded?

share|improve this question
1  
Please don't change the question to something completely different, since it becomes really hard to follow the discussion, and the answers start to sound terribly unrelated. –  Adrian Lang Nov 22 '12 at 12:46
add comment

3 Answers

On ubuntu, while working on localhost, the php.ini file which gets load is located in your php(say latest php5) folder, path is /etc/php5/apache2/php.ini, this file basically controls the memory for localhost, like if you want to increase the db upload size or increase your memory limit on your localhost, then you need to edit this file.

share|improve this answer
    
Yes but in that file I changed the auto_prepend line to the following: auto_prepend_file = "/media/d1/website/csite/auto_prepend.html". But that auto_prepend file still doesn't get automatically prepende like on server and my other localhost system. –  Hermann Ingjaldsson Nov 22 '12 at 9:23
    
now have changed the question.. what is the error, can you specify?? –  Coder anonymous Nov 22 '12 at 10:18
    
There is an auto_prepend option in the php.ini file which I have set and for some reason nothing gets appended to the files on localhost. –  Hermann Ingjaldsson Nov 22 '12 at 10:24
add comment

The pre-appended file should be a php file IIRC, unless you are parsing html as php.

share|improve this answer
    
well prepending this html file this way has worked in other Ubuntu systems already so it's gotta be ok. –  Hermann Ingjaldsson Nov 22 '12 at 9:51
add comment

This question seems to be mutating as you dig deeper into the problem (as is right and proper, and often the case!) so I'll bite. The location of php.ini is embedded at compile time for the module, via the options --with-config-file-path= and --with-config-file-scan-dir=. Both the value of these compile-time options, and the actual php.ini it finds and parses as a result, can be seen into the output of phpinfo(). For the avoidance of doubt: php doesn't look into the DocumentRoot for this file, as your current question presumes.

You can have it look anywhere you want it to, but you'll have to recompile the module yourself.

share|improve this answer
    
Ok so where do I change those --with-config-file options? And how do I recompile the module? –  Hermann Ingjaldsson Nov 22 '12 at 12:56
    
Sorry, how to do stuff like that is beyond the scope of a simple SF answer. You'll need to do a bunch of research, or get someone who knows about Linux to do it for you. If you're not familiar with this stuff, then your life will be much simpler if you just put php.ini where it's supposed to go. If you don't have privilege to do that, you also don't have privilege to insert a recompiled module, so you can't do any of this. –  MadHatter Nov 22 '12 at 13:05
    
Yes but even when i put the php.ini where it's supposed to go, the auto_append still doesn't work. –  Hermann Ingjaldsson Nov 22 '12 at 13:06
1  
Then I submit you are confused, and do not currently know whether the issue is that php is not picking up the .ini file, or that what you've added to it is not a valid statement for the setup of php on this machine. Until you know what your problem is, it will be hard to solve. And if I may presume, just because what you're trying to do worked on another machine is no reason whatsoever that it should work on this machine. The number of compile-time options that can be set (see phpinfo() output) should give you some indication of how much PHP can vary from one machine to another. –  MadHatter Nov 22 '12 at 13:11
add comment

Your Answer

 
discard

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.