doutuo6689 2013-10-05 22:49
浏览 37
已采纳

如何在没有时间限制的情况下在生产中迁移单个(php || javascript || ...)文件

I have simple files (php||javascript||...) running in production (apache+(php||javascript||...)).

I am trying to think to the proper way of migrating a simple file while not stopping serving web clients.

Possible influences are:

  • Apache cached files: I do not know how apache deal with files (php, img, ...). Does it cache them, and check for update timestamp to reload, or does it reload on each http request ?
  • Linux files are changed in an atomic manner: If I cp a file with new content, apache can only see the full content final save results of my command ?
  • Apache execution process: Can I pause Apache, holding current requests, while copying new file versions.

I imagine the following:

  • Have files, like php require_once file, named with versions (ex: ABusinessClassD-v1.0.php), support backward compatibility, and simply do a cp of new files one by one, going from bottom up (database, static files (img, ...), php files, javascript files, ...)
  • Force refresh browser code on demand.

Imagination != as simple as this != Reality.

Please, can somebody summarize globally simple manual steps to update a simple file in an apache production, without stopping serving web clients, in a manual intentionally slow process ?

  • 写回答

1条回答 默认 最新

  • duankuangxie9070 2013-10-05 22:59
    关注

    The only sure way to guarantee no issues when moving over a PHP codebase would be to have two servers or two deployments on the same server.

    You have Server 1 which contains your old code. Server 2 is set up with the new code. Then, your DNS records or load balancer/proxy settings are changed so your site is instead served from Server 2.

    Or with one server, you configure Apache to serve your application from /path/to/old, and then set up your new version in /path/to/new. Then you change your Apache configuration to use /path/to/new for the application and restart the server.

    If you ever need to use version numbers in file names (ABusinessClassD-v1.0.php) then you need to learn about version control software like Git or Mercurial.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助