MAC OSX 上的 php.ini 配置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9733342/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 07:31:45  来源:igfitidea点击:

php.ini Configuration on MAC OSX

phpmacosapache

提问by Sarthak Gupta

I am experiencing a strange problem with PHP configurations file php.ini on mac osx. I have created a phpinfo file. Calling it in the browser shows the php settings with -

我在 mac osx 上遇到了 PHP 配置文件 php.ini 的奇怪问题。我创建了一个 phpinfo 文件。在浏览器中调用它会显示 php 设置 -

**Configuration File (php.ini) Path : /etc

* *配置文件(php.ini)路径:/etc

Loaded Configuration File : /private/etc/php.ini**

加载的配置文件:/private/etc/php.ini**

However upon editing the php.ini file at this location, (and restarting Apache of course) the changes are not reflected in the php settings as well as the phpinfo file. e.g.: changing the bcmath decimal digits, changing timezone settings etc. Is there another primary location from where Apache will pick up the settings file. Any help would be highly appreciated.

但是,在此位置编辑 php.ini 文件(当然还需要重新启动 Apache)时,更改不会反映在 php 设置和 phpinfo 文件中。例如:更改 bcmath 十进制数字,更改时区设置等。是否有另一个主要位置,Apache 将从该位置获取设置文件。任何帮助将不胜感激。

回答by Jeremy John

This is an old post, but I had this problem and scoured the internet to no avail, so I answer here for posterity.

这是一个旧帖子,但我遇到了这个问题并在互联网上搜索无济于事,所以我在这里回答后代。

I'm using native Mac OSX apache2 with homebrew taps from josegonzales.

我正在使用原生 Mac OSX apache2 和来自 josegonzales 的自制软件

To quote my sysadmin friend, "the answer should lie in restarting PHP-FPM instead of Apache. Apache uses mod_fastcgi to connect to PHP via a port or socket that PHP-FPM runs php with."

引用我的系统管理员朋友的话,“答案应该在于重新启动 PHP-FPM 而不是 Apache。Apache 使用 mod_fastcgi 通过 PHP-FPM 运行 php 的端口或套接字连接到 PHP。”

You need to load/unload the plist file associated with your PHP-FPM install. First check ~/Library/LaunchAgents Not there? Mine was located here: /usr/local/Cellar/php53/5.3.26/homebrew-php.josegonzalez.php53.plist

您需要加载/卸载与 PHP-FPM 安装关联的 plist 文件。首先检查 ~/Library/LaunchAgents 没有?我的位于这里: /usr/local/Cellar/php53/5.3.26/homebrew-php.josegonzalez.php53.plist

It's restarted like this: launchctl unload -w /usr/local/Cellar/php53/5.3.26/homebrew-php.josegonzalez.php53.plist && launchctl load -w /usr/local/Cellar/php53/5.3.26/homebrew-php.josegonzalez.php53.plist;

它是这样重新启动的: launchctl unload -w /usr/local/Cellar/php53/5.3.26/homebrew-php.josegonzalez.php53.plist && launchctl load -w /usr/local/Cellar/php53/5.3.26/homebrew-php.josegonzalez.php53.plist;

I added the following to my ~/.bash_profile so that I can restart PHP-FPM when I restart apache. The command to invoke the following is "apachectlrestart"

我在 ~/.bash_profile 中添加了以下内容,以便在重新启动 apache 时可以重新启动 PHP-FPM。调用以下命令的命令是“apachectlrestart”

function apachectlrestart () { sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist && sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist && launchctl unload -w /usr/local/Cellar/php53/5.3.26/homebrew-php.josegonzalez.php53.plist && launchctl load -w /usr/local/Cellar/php53/5.3.26/homebrew-php.josegonzalez.php53.plist;}

回答by a20

Glassdimly's answer helped me to fix this problem.

Glassdimly 的回答帮助我解决了这个问题。

Problem:

问题:

  • 'Loaded configuration file'shows '/usr/local/etc/php/7.0/php.ini'in phpinfo()output, and my module(imagick) is not getting loaded by php.

  • I tried manually including my module in the main php.ini file and restarting apache but 'Loaded configuration file'did not update.

  • I tried killing all instances of apache and restarting apache - still same.

  • I tried renaming my php.inito php.ini_and restarted apache but 'Loaded configuration file'is still showing the old php.inifile.

  • 'Loaded configuration file'显示'/usr/local/etc/php/7.0/php.ini'phpinfo()输出中,我的模块(imagick)没有被 php 加载。

  • 我尝试手动将我的模块包含在主 php.ini 文件中并重新启动 apache 但'Loaded configuration file'没有更新。

  • 我尝试杀死 apache 的所有实例并重新启动 apache - 仍然相同。

  • 我尝试将我的重命名php.iniphp.ini_并重新启动 apache,但'Loaded configuration file'仍然显示旧php.ini文件。

Solution:

解决方案:

  • After reading Glassdimly's answer above, I tried these steps:

  • launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php70.plist

  • launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php70.plist
  • And boom - it worked!
  • Next I set up shortcut function inside my ~/.bash_profile:

    # restart php-fpm
    function restart_fpm(){
    
        plist=~/Library/LaunchAgents/homebrew.mxcl.php70.plist
    
        launchctl unload -w $plist
        launchctl load -w $plist
    
        echo "PHP 7 fpm restarted"
    }
    
  • source ~/.bash_profileloads the new function into the current shell
  • 在阅读了上面 Glassdimly 的回答后,我尝试了以下步骤:

  • launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php70.plist

  • launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php70.plist
  • 繁荣 - 它奏效了!
  • 接下来我在我的里面设置快捷功能~/.bash_profile

    # restart php-fpm
    function restart_fpm(){
    
        plist=~/Library/LaunchAgents/homebrew.mxcl.php70.plist
    
        launchctl unload -w $plist
        launchctl load -w $plist
    
        echo "PHP 7 fpm restarted"
    }
    
  • source ~/.bash_profile将新函数加载到当前 shell 中

Hope this helps some fellow desperate Googler from the future!

希望这能帮助一些未来绝望的谷歌员工!

回答by NarayaN

restarting your apache server from services panel will reflect your new changes made....

从服务面板重新启动您的 apache 服务器将反映您所做的新更改....