Where is PHP.ini in Mac OS X Lion? Thought it was in /usr/local/php5/lib
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.
On my old machine it was located in /usr/local/php5/lib But php5 directory doesn’t exist in /usr/local..
Do I need to get a package or am I looking in the incorrect place?
Running OS X 10.7.3, PHP 5.3.8, Apache/2.2.21
12 Answers 12
You should find it in /private/etc if it exists, otherwise:
To locate the ini file on your machine, open Terminal.app and run the following command:
If you need a template for Lion, try this.
In terminal do php -i | grep php.ini . Should give you some clues 😉
Answers from @Cronk and @Justin got me close on Mac OS X 10.9 Mavericks. In fact, on my system the /etc/php.ini file was missing completely, and it wasn’t until I ran phpinfo() on the web server that I observed there was no configuration file. Copying the file from /etc/php.ini.default and adding the fully qualified path to the mcrypt.so library to the config file solved the problem:
Then in /etc/php.ini add the following line (using the correct path to your mcrypt.so file):
Then restart Apache2:
As pointed out, the php —ini command will tell you where PHP is expecting to find the php.ini file.
For a standard installation, it’s likely to be looking for /etc/php.ini
If you’ve used macports then PHP may be looking for /opt/local/etc/php5/php.ini
Run phpinfo() from any file and it tells you where it is. Here is a screenshot.
I have more than once instance of PHP running so the other answers did not work for me. This did:
Create a PHP file and open its local url in your browser:
The PHP.INI path will be listed close to the top.
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:
For the php.ini file path things were different, too:
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.
I start with the ‘Hello World!’, once I get that displaying in my browser I throw a phpinfo(); in there and you can see all of the things. Tells you which configurations are loaded, everything.
On OSX/MacOS do the following in a Terminal window:
Run php —ini at the prompt by typing it and pressing enter
Reports something like: Configuration File (php.ini) Path: /etc Loaded Configuration File: (none) Scan for additional .ini files in: /Library/Server/Web/Config/php Additional .ini files parsed: (none)
. this is because in /etc there is a file called /etc/php.ini.default as an example and to show it is not in use. You need to copy that file to the name php expects so that you can edit it, like this:
. then you will see if you run php —ini again that it now sees your new file:
Typing this: php —ini at the prompt should report this:
. now edit /etc/php.ini — you want to make sure the following lines (NOT the same line starting with a semi-colon ‘;’) are exactly as follows: log_errors = On (this will turn the logging engine on)
Then, in this section:
If you want to log to the syslog (or Windows Event Log on Windows) then ;error_log = syslog should become error_log = syslog
Question: Q: Where is PHP.INI file
I want to change few setting in php.ini which phpinfo.php shows it is in /etc but when look it is not there. I did a search using locate php.ini and cannot find it.
Any idea where Mac keep it?
MacBookpro 17″, Mac OS X (10.6.3)
Posted on Jun 1, 2010 2:18 AM
All replies
Loading page content
Page content loaded
I’ve already done but when I change for example
upload maxfilesize= 20M
The change did not show in phpinfo.php
It looks like it is not PHP is not reading it.
Jun 1, 2010 12:05 PM
Unfortunately, no. I think your system is still seriously jacked up and needs a reinstall.
Works fine here. Pretty sure you’ve broken that and who knows what other things. I think maybe it’s time for you to reinstall.
Jun 3, 2010 11:38 AM
alkhater wrote:
I have removed all other apache and php from the system. Searching via locate in terminal, I found only one php.ini, and it is in /etc, and it is the one I copied from default.php.ini
but when change any setting in it it does not show in phpinfo.php
Are you restarting Apache after changing the settings?
alkhater wrote:
I switch web sharing on/off. does that re-start apache or there is another way?
That will do it. You can also run «sudo apachctl»
I had a similar issue. I found a php.ini in several directories for example:
/usr/local/php5/lib/php.ini
In the end the only way I could get the phpinfo to show the correct value was to either put the php.ini file in /etc/ or to make a symbolic link (ln -s /usr/local/php5/lib/php.ini php.ini) within the /etc/ directory. No location that the php.ini file was created would work, and the .default file is not read either. Lesson learned.
Restart web sharing in the control panel afterwards.
Works on 10.4 and 10.5 that I tried.
Где PHP.ini в Mac OS X Lion? Думал, что это было в / usr / local / php5 / lib
Я хотел запустить некоторый PHP прямо на моем Mac, uncommented httpd.conf, активировал общий доступ к сети, установил MySQL и т. Д. Я не могу найти файлы PHP, а самое главное, PHP.ini.
На моей старой машине он находился в / usr / local / php5 / lib Но директория php5 не существует в / usr / local ..
Нужно ли мне получить пакет или я ищу неправильное место?
Запуск OS X 10.7.3, PHP 5.3.8, Apache / 2.2.21
Вы должны найти его в / private / etc, если он существует, иначе:
Чтобы найти файл ini на вашем компьютере, откройте Terminal.app и выполните следующую команду:
Если вам нужен шаблон для Lion, попробуйте это .
В терминале do php -i | grep php.ini php -i | grep php.ini . Должны дать вам некоторые подсказки;)
Как указано, команда php —ini сообщит вам, где PHP ожидает найти файл php.ini.
Для стандартной установки он, вероятно, будет искать /etc/php.ini
Если вы использовали macports, то PHP может искать /opt/local/etc/php5/php.ini
Запустите phpinfo() из любого файла, и он сообщит вам, где он находится. Вот скриншот.
Ответы @Cronk и @Justin заставили меня закрыть Mac OS X 10.9 Mavericks. Фактически, в моей системе файл /etc/php.ini отсутствовал полностью, и только после того, как я запустил phpinfo() на веб-сервере, я заметил, что не было файла конфигурации. Копирование файла из /etc/php.ini.default и добавление полного mcrypt.so библиотеку mcrypt.so в файл конфигурации решает проблему:
Затем в /etc/php.ini добавьте следующую строку (используя правильный путь к вашему файлу mcrypt.so ):
Затем перезапустите Apache2:
У меня уже не один экземпляр PHP работает, поэтому другие ответы не сработали для меня. Это произошло:
Создайте файл PHP и откройте его локальный url в своем браузере:
Путь PHP.INI будет указан ближе к вершине.
Это довольно старая нить, но я хотел бы добавить дополнительное разъяснение.
Если у вас есть система с несколькими установками PHP (как и мои), результаты, полученные вами с помощью инструментов командной строки, могут быть разными, чем то, что фактически используется веб-сервером. Если вас интересует, что PHP используется веб-сервером, используйте информацию, собранную с веб-страницы, использующей функцию «phpinfo ()».
Например, в моей системе версии, описанные двумя разными способами, были:
Для пути к файлу php.ini все было по-другому:
Вы можете найти все возможные файлы php.ini, используя это:
find / -name php.ini 2> & 1 | grep -v «denied» | grep -v «directory»
(элементы ‘2> & 1’ и ‘grep’ просто ограничивают вывод команды полезной информацией, то есть избавляются от сообщений об ошибках)
В моей системе я нашел 3 INI-файла. Поскольку меня интересовало то, что использовал веб-сервер, я знал, что должен использовать путь, возвращенный с результатов веб-страницы. Я внес изменения в файл php.ini, который был указан там, перезапустил apache и повторно запустил веб-страницу; там были показаны новые изменения.
Чтобы перезапустить apache:
Я начинаю с «Hello World!», Как только я получаю это отображение в своем браузере, я бросаю phpinfo(); там, и вы можете видеть все. Сообщает вам, какие конфигурации загружены, все.
Вы запускаете php_info () и смотрите строку ниже: