Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
215 views
in Technique[技术] by (71.8m points)

php - How to update a website without making it go down?

I need the best practice for updating one or more files on my website without making it go down;

example, if i update Model.php file, the upload will take few seconds, like one or two seconds before it replaces the file on the server, in the meantime, the website will show some error that model.php is not found, or not complete, even if i suppress the errors, the website will die eventually.

what is the best practice for that?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

One practice I've often used and seen in practice is -

  • use a Version Control System (VCS) like SVN or Git

  • on the live server, make the site's web root a symbolic link to a directory containing the latest revision of your web site (eg. /www/domain.com/r555) for revision no. 555

  • when a change comes up, check in changes to the VCS

  • have a script that checks out the latest revision to a new directory, carrying the revision name (say, /www/domain.com/r556)

  • when the checkout is done, change the symbolic link and make it point to /www/domain.com/r556.

There are a few snags if you have dynamic data like file uploads and such that you can't have in the VCS, but they can all be dealt with without downtime.

Things like database changes may still require some kind of maintenance mode, though.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...