git - 开源项目部署时,如何处理那些敏感的配置项比较方便?
PHP中文网
PHP中文网 2017-05-02 09:42:08
0
2
548

最近在做一些开源项目:

平常在公司部署项目,因为Git仓库私有的,所有根据不同环境有配置文件,config-template.jsonconfig-onlone.json类似的等等。在部署的时候,部署脚本替换下这些文件就好了。

但是做开源项目的话,配置文件不能提交到版本库。这样就不能直接替换了。

目前我的是做法是在部署服务器上写好配置文件,然后部署的时候替换为正式配置文件。但是因为配置文件放在服务器,感觉不好维护,特别是那些配置项比较多的。有变化就要上服务器上面去改,比较麻烦。

不知道大家有没有什么更方便的维护这些配置文件的方法吗?谢谢大家

PHP中文网
PHP中文网

认证0级讲师

reply all(2)
黄舟

Submit a configuration file in the same format as the official one to the code repository, such as the following
config-template.json

{
    "mysql":{
        "host":"mysql_host",
        "port":3306
    }
}

When reading the program, you can first determine whether there is config.json. If there is, use it. If not, an error will be reported.
config.json is the configuration of the official environment and cannot be submitted online

左手右手慢动作

Deployed with ansible.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!