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 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用