简体   繁体   中英

How to upload changes automatically?

I'm developing a simple website(in a VPS) using php. My question is: how can I send the changes I do using a secure protocol? At the moment I use scp but I need a software that check if the file is changed, if yes sends it to the server.

Advice?

use inotify+rsync or lsyncd http://code.google.com/p/lsyncd/

check out this blog post for the inotify method http://www.cyberciti.biz/faq/linux-inotify-examples-to-replicate-directories/

If you have complete access to your VPS, then you can mount your remote home directory, via ssh and webdav, locally as a normal filesystem. Afterwards you can edit on your computer locally. Any changes should be automatically uploaded.

Have a look at this relevant article

  • FTP(S): Set up an FTP server on the target, together with an SSL cert (a personal cert is good enough).

  • SSH: You can pass files around through SSH itself, but I found it most unreliable (imho).

  • Shares: You could share a folder (as the other people suggested) with your local machine. This would be the perfect solution if it wasn't hard at diagnosing disconnection issues. I've been through this and it is far from a pleasant experience.

  • Dropbox: Set up a dropbox server on your VPS and a dropbox client on your local PC. Using dropbox (or similar methods like skydrive, icloud..), also has some added advantages, eg, versioning, recovery, conflict detection...

All in all, I think the FTPS way is the most reliable and popular one I've ever used. Via SSH, it caused several issues after using it from about 2 days. The disk sharing method caused me several issues mostly because it requires that you are somewhat knowledgeable with the protocol etc. The dropbox way, although a bit time-consuming to set up, is still a good solution. However, I would only use it for larger clients, not the average pet hobby website :)

Again, this is just from experience.

You could also use Subversion to do this, although the setup may take a little while.

You basically create a Subversion repository and commit all of your code. Then on your web server, make the root directory a checkout of that repository.

Create a script that runs a svn update command, and set it as a post-commit hook. Essentially, the script would be executed every time you would do a commit from your workstation.

So in short, you would...

  1. Update your code locally
  2. Commit via Subversion (use Tortoise SVN, it's easy and simple to use)
  3. Automatically, the commit would trigger the post-commit hook on the server and run the svn update command to synchronize the code in your root directory.

You would of course have to hide all of the .svn folders to the public using .htaccess files (providing you're using Apache).

I know this would work, as I have done it in the past.

The beauty of this option is that you also get a two in one. Source versionning and easy updates. If you make a mistake, you can also easily revert them back.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM