开发者

How can I have my CMS upgrade itself?

开发者 https://www.devze.com 2023-04-08 10:42 出处:网络
I\'ve built a CMS (using the Codeigniter PHP framework) that we use for all our clients. I\'m constantly tweaking it, and it gets hard to keep track of which clients have which version. We really want

I've built a CMS (using the Codeigniter PHP framework) that we use for all our clients. I'm constantly tweaking it, and it gets hard to keep track of which clients have which version. We really want everyone to always have the latest version.

I've written it in a way so that updates and upgrades generally only involve uploading the new version via FTP, and deleting the old one - I just don't touch the /uploads or /themes directories (everything specific to the site is either there or in the database). Everything is a module, and each module has it's own version number (as well as the core CMS), as well as an install and uninstall script for each version, but I have to manually FTP the files first, then run the module's install script from the control panel. I wrote and will continue to write everything personally, so I have complete control over the code.

What I'd like is to be able to upgrade the core CMS and individual modules from the control panel of the CMS itself. This is a "CMS for Dummies", so asking people to FTP or do anything remotely technical is out of the question. I'm envisioning something like a message popping up on login, or in the list of installed modules, like "New version available".

I'm confident that I can sort out most of the technical details once I get this going, but I'm not sure which direction to take. I can think of ways to attempt this with cURL (to authenticate and pull source files from somewhere on our server) and PHP's native filesystem functions like unlink(), file_put_contents(), etc. to preform the actual updates to files or stuff the "old" CMS in a backup directory and set up the new one, but even as I'm writing this post - it sounds like a recipe for disaster.

I don't use gi开发者_Go百科t/github or anything, but I have the feeling something like that could help? How should (or shouldn't) I approach this?


Theres a bunch of ways to do this but the least complicated is just to have Git installedo n your client servers and set up a cron job that runs a git pull origin master every now and then. If your application uses Migrations it should be easy as hell to do.

You can do this as it sounds like you are in full control of your clients. For something like PyroCMS or PancakeApp that doesn't work because anyone can have it on any server and we have to be a little smarter. We just download a ZIP which contains all changed files and a list of deleted files, which means the file system is updated nicely.

We have a list of installations which we can ping with a HTTP request so the system knows to run the download, or the click can hit "Upgrade" when they log in.


You can use Git from your CMS: Glip. The cron would be a url on your own system, without installing Git.


@Obsidian Wouldn't a DNS poisoning attack also compromise most methods being mentioned in this thread?

Additionally SSH could be compromised by a man in the middle attack as well.

While total paranoia is a good thing when dealing with security, Wordpress being a GPL codebase would make it easy to detect an unauthorized code change in your code if such an attack did occur, so resolution would be easy.

SSH and Git does sound like a good solution, but what is the intended audience?


Have you taken a look at how WordPress does it? That would seem to do what you want. Check this page for a description of how it works. http://tech.ipstenu.org/2011/how-the-wordpress-upgrade-works/

0

精彩评论

暂无评论...
验证码 换一张
取 消