普通网友 2017-06-07 11:30
浏览 67
已采纳

如何正确使用Git。 使用带有DEVELOPMENT,TESTING和PRODUCTION服务器的CodeIgniter

Basically, I have a file index.php which should be different in each server. The file indicates which server it is on.

It has something like this:

On the DEVELOPMENT environment:

define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');

On the TESTING environment:

define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'testing');

On the PRODUCTION environment:

define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'production');

What's the proper way to maintain these files on each server without Git touching it?

I've added the file to .gitignore now, and I've untracked it using git rm --cached index.php then git push origin master for TESTING server and stable for PRODUCTION server.

  • 写回答

2条回答 默认 最新

  • duanfu1945 2017-06-07 11:57
    关注

    fyi,

    if you use apache you don't really have to change the index.php file because you can use your htaccess file to define your environment

    for example :

    SetEnvIf Host yourdevdomain$ CI_ENV=development
    SetEnvIf Host yourtestdomain$ CI_ENV=testing
    SetEnvIf Host example.com$ CI_ENV=production
    

    In this case, you can set your needed Environments in your htaccess file, and you don't have to worry about overwriting some stuff with different files from different environments.

    i think there is an option on nginx too

    Take a look here

    You can get more information from the official CI Documentation here.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!