如何在生产和开发中管理不同的 php.ini 设置?
是否有管理从开发到生产的 php.ini 配置的最佳实践?显然,这可以手动完成,但这很容易出现人为错误。我想尝试将生产文件置于版本控制中,然后可能自动修改开发版本。 我的想法或想法我不知道它们是否可行:
- php.ini 包含 - 只需在末尾包含开发设置 文件?
- 从 apache conf 进行条件加载?
- 编写一个脚本,当 php.ini 更改时,生成 phpdev.ini 的动态版本 - (我知道这可以完成)
- 使用运行时 php 设置来显示错误 - 我认为这有局限性,因为如果脚本有致命错误,那么它不会运行运行时设置。
- 备份计划 - 将生产版本保留在 SC 中,并手动更改 phpdev.ini 根据需要按需配置。那么如果人为失误 它们是在开发级别完成的。
Is there a best practice for managing php.ini configurations from development to production? Obviously it can be done manually, but that is prone to human error. I'd like to try and have the production file in version control and then possibly modify the development version automatically.
Thoughts or ideas i've had which i dont know if they are feasible:
- php.ini includes - just include the dev settings at the end of
the file? - conditional loads from apache conf?
- write a script that when php.ini changes, a dynamic version of phpdev.ini gets generated - (i know this can be done)
- use runtime php settings for display errors - i think this has limitations because if the script has fatal errors, then it wont run the runtime setting.
- backup plan - keep the production version in SC, and manually change
phpdev.ini as needed as needed. Then if manual mistakes are made
they are done at the development level.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
rm /etc/php.ini; ln -s /var/www/site/environments/prod/php.ini /etc/php.ini
这样,您就可以获得版本控制的好处,而不必手动编辑每个版本。
rm /etc/php.ini; ln -s /var/www/site/environments/prod/php.ini /etc/php.ini
This way, you get the benefits of revision control and don't necessarily have to edit each manually.
我不确切知道这是否是您正在寻找的,但我个人喜欢通过 apache 虚拟主机设置执行所有非安全必要的 php.ini 修改,例如开发虚拟主机:
等
I don't know exactly if this is what you're looking for, but personally I like to perform all non-security-necessary php.ini modifications via the apache virtualhost settings, e.g. a development virtualhost:
etc