如何管理生产和开发不同的php.ini设置?不同、php、ini

2023-09-02 09:52:08 作者:你马子真不赖

有管理的php.ini配置从开发到生产的最佳实践?显然,这可以手动完成,但是这是容易出现人为错误。我想尝试并在版本控制生产文件,然后可能自动修改开发版本。 想法或意见我有过,我不知道他们是否是可行的:

在php.ini中包括 - 只包括在年底的开发设置 该文件? 来自Apache的conf 在有条件的负荷? 在编写一个脚本,在php.ini中的变化,获取生成phpdev.ini的动态版本 - (我知道这是可以做到) 显示错误使用运行PHP的设置 - 我认为这有一定的局限性,因为如果脚本有致命错误,那么它不会运行,运行时设置。 备份计划 - 保持量产版的SC,并手动更改 phpdev.ini因为需要必要的。然后,如果人工错误是由 他们在发展水平做了。 解决方案 存储你的ini在源$ C在他们的环境中而得名不同的目录$ C库:环境/ {开发,QA​​,分期,督促} /php.ini 在每一个环境下,做到这一点: RM /etc/php.ini中; LN -s /var/www/site/environments/prod/php.ini /etc/php.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.

解决方案 Windows 2008 R2 IIS 7.5 下以 FastCGI 方式运行 PHP 7.x,php cgi无法常驻内存,请求结束即退出

Store your ini in your source code repository in different directories named after their environments: environments/{dev,qa,staging,prod}/php.ini On each environment, do this: 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.