上传重要文件时网站无法运行
我在维护基于 php 的网站时遇到问题。我的网站是基于 Zend 框架构建的。当我希望在线上传新副本或版本时 - 在上传期间,尤其是在上传和重写模型和控制器等关键文件时 - 该网站将无法正常运行。
有没有办法上传网站而不必经历这个问题?
我的更新真的很规律。在这种情况下,我们可以说每周一次或两次。
I have a problem with maintenance of my php based website. My website is built on the Zend Framework. When I wish to upload a new copy or version online - during the time of upload especially when crucial files like models and controllers are being uploaded and rewritten - the site won't run understandably.
Is there a way to upload a website without having to go through this issue?
My updates are really quite regular. Let's say like once or twice a week in this case.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以利用即使通过 FTP 也可以快速轻松地重命名目录这一事实。我通常做的是:
有两个目录,
website_live
和website_upload
website_live
包含实时网站(显然)将内容上传到
website_upload
将
website_live
重命名为website_old
(或其他名称)将
website_upload
重命名为website_live
完成!如果您快速重命名,停机时间不到两秒。
如果您在旧版本(例如从 CMS)中上传了内容,并且需要将其转移到新版本,那么情况会变得更加复杂。每次都手动执行很麻烦,但基本上也只是简单的重命名操作(在 FTP 中重命名也毫不费力)。
使用简单的部署脚本可以很好地实现此任务的自动化。如果您使用的是 Linux,则为此设置 shell 脚本很容易。在 Windows 上,我使用过一个非常好的工具来进行自动 FTP 同步、重命名和错误处理 - 即使非技术人员也可以开始该过程 - 是 ScriptFTP。它配备了良好的脚本语言和良好的文档。但它不是免费的。
如果您希望进入核心自动化 PHP 部署,我最近一直在该领域进行一些研究。也许是我最近的赏金问题的答案可以给你灵感。
You can make use of the fact that renaming directories is quick and easy even through FTP. What I usually do is:
Have two directories,
website_live
andwebsite_upload
website_live
contains the live website (obviously)Upload contents to
website_upload
Rename
website_live
towebsite_old
(or whatever)Rename
website_upload
towebsite_live
done! Downtime less than two seconds if you rename quickly.
It gets a bit more complex if you have uploaded content in the old version (e.g. from a CMS) that you need to transfer to the new one. It's cumbersome to do manually every time, but basically, it's just simple rename operations too (renaming works effortlessly in FTP as well).
This is a task that can be automated quite nicely using a simple deployment script. If you're on Linux, setting up a shell script for this is easy. On Windows, a very nice tool I've worked with to do automated FTP synchronizing, renaming and error handling - even with non-technical people starting the process - is ScriptFTP. It comes with a good scripting language, and good documentation. It's not free, though.
If you're looking to get into hard-core automated PHP deployment, I've been doing some research in that field recently. Maybe the answers to my recent bounty question can give you inspiration.