Where is PHP.ini in Mac OS X Lion? Thought it was in /usr/local/php5/lib

前端 未结 12 2283
醉话见心
醉话见心 2020-11-29 15:13

I wanted to run some PHP right on my Mac, uncommented httpd.conf, activated web sharing, installed MySQL etc. I can\'t seem to find my PHP files, most importantly, PHP.ini.<

12条回答
  •  孤街浪徒
    2020-11-29 15:24

    This is rather old thread, but I would like to add a further clarification.

    If you have a system that has multiple PHP installations (like mine did) the results you get from using the command line tools MAY BE different than what is actually used by the web server. If you are interested in what PHP is being used by the web server, only use the information gathered from a web page that uses the 'phpinfo()' function.

    For example, on my system the versions reported by the two different methods were:

    Command line: 5.3.26

    Web: 5.3.13

    For the php.ini file path things were different, too:

    Command line: /private/etc/php.ini

    Web: /long/path/to/the/file/php.ini

    You can find all the possible php.ini files using this:

    find / -name php.ini 2>&1 | grep -v "denied" | grep -v "directory"

    (the '2>&1' and 'grep' elements just restrict the output of the command to useful information, i.e. get rid of error messages)

    On my system I found 3 INI files. Because I was interested in what the web server was using I knew that I should use the path returned from the web-page results. I made my changes to the php.ini file that was listed there, restarted apache, and re-ran the web page; the new edits were shown there.

    To restart apache:

    sudo apachectl -k restart

    -- J

提交回复
热议问题