-1

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?

MadHatter
  • 78,442
  • 20
  • 178
  • 229
john-jones
  • 75
  • 13
  • 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 Heine Nov 22 '12 at 12:46

3 Answers3

2

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.

John Gardeniers
  • 27,262
  • 12
  • 53
  • 108
  • 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. – john-jones Nov 22 '12 at 09: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. – john-jones Nov 22 '12 at 10:24
0

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

melsayed
  • 1,124
  • 1
  • 6
  • 11
0

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.

MadHatter
  • 78,442
  • 20
  • 178
  • 229
  • Ok so where do I change those --with-config-file options? And how do I recompile the module? – john-jones 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. – john-jones 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