php.ini not working

I can't seem to make any changes to my php.ini file and get them to work. I'm using the one is /etc. I've restarted Apache and the computer, but every time I look at the info file, it's the same. Is there some other place it could be pulling the .ini info from? I've got this info and these are the files I'm changing?

Configuration File (php.ini) Path /etc
Loaded Configuration File /private/etc/php.ini

I'm changing upload maxsize and things like that. They are uncommented so it's not that. What could interfere with this?

Thanks!

Mac Mini Server, Mac OS X (10.6.4), MacBook Pro 15"

Posted on Feb 17, 2011 11:00 PM

Reply
5 replies

Mar 24, 2011 4:30 AM in response to Patrick Maun1

I have the same problem with my php.ini file not being recognized. It all started with the MySQL socket and I am trying to follow the instructions to change "mysql.default_socket" to "/tmp/mysql.sock". php is looking in /var/mysql/ for the socket.

I did not have a php.ini file so I copied php.ini.default. Then I changed the two mysql lines and saved. The owner and group are correct.

My phpInfo display says the same as Patrick's above. However, the mysql socket location is still /var/mysql so php is apparently not reading the php.ini. I did try a restart of my iMac and still no resolution.

So, what can I do to make php see the php.ini file in /etc?

Thank you for any help!

Mar 24, 2011 10:10 AM in response to Jane L

Well I'm far from a php OS X expert but I've gotten the software running on a few different macs as well as unix systems and as no one else seems to be jumping in on this let me give it a try.

First if phpinfo() is reporting that it loaded php.ini configuration file then that is the file that was loaded.
Now it is possible that while editing the .ini file you introduced something into the file that caused a syntax error then php would continue to use the previous contents of the file.

So as a first step I would look in the Console at the apache access_log and especially the error_log and see if anything jumps out. You can narrow down the search by typing php into the search box at the top of the Console app window.

If nothing appears obvious then I would go back to the original php.ini.default file rename it to php.ini restart apache and see what phpinfo() shows. Then make you edits to the file one at a time and restarting between each edit and see if phpinfo() reflects the change.

Remember syntax errors can be something as silly as an extra whitespace or a bad line ending or my favorite (at least for some shell scripts, don't know if php suffers from it also) is a line that should be empty, that is only have a CR but instead has a space followed by a CR.

good luck

Message was edited by: Frank Caggiano

Mar 24, 2011 10:31 AM in response to Patrick Maun1

php.ini is read only once: when the web server starts. I'm guessing that you modified php.ini and did not restart the web server. Go to System Preferences > Sharing and uncheck Web Sharing. Wait a second, then check it to turn web sharing back on. This has the effect of restarting the web server and php.ini will be reloaded.

In this case, it's not necessary, however, since you can set upload maxsize in your .htaccess file. So, there's no need to restart the web server if you simply change it there instead of php.ini.

Mar 25, 2011 4:25 AM in response to Frank Caggiano

While J D McIninch is correct, that I had to stop and start the Apache2 server to get the new php.ini file, I had been doing that all along.

Frank Caggiano was correct, I had two things wrong with my php.ini file. First, there was a character before [PHP] at the very beginning of the file. And I had to switch the line endings to Unix-Mac OS X (lf) I am using Smultron which was working pretty well except for those pesky line endings.

So, yes if there is anything wrong in the php.ini file, it will not parsed and be used.

In my travels trying to find a solution, I noticed that many people were using TextWrangler from Bare Bones Software to edit system files. It's free and you can get it here:

http://www.barebones.com/products/textwrangler/

And I found an alternate php binary source for Snow Leopard at MacPorts. You can see it here:

http://www.macports.org/index.php

When you download php5, you also get a different Apache2 server. But I didn't use that; I modified the httpd.conf file for my Apple Apache2 server to point to the php module from MacPorts. This did work but when I fixed my php.ini, I went back to Apple's php5.

Thank you J D McIninch and Frank Caggiano for replying to my post. I appreciated your help.

Message was edited by: Jane L

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

php.ini not working

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.