Deploying updates to a website

Hi,

What are some good ways of streamlining updates to a website? For example, say I have a software project in version control and I want to release a new version. My current process is:

1. Build an archive containing the new software. (software-1.1.zip)

2. SCP this file to my server.

3. SSH into my server.

4. Use sudo to copy the file into the correct location (Since the website is running as the apache user and my user doesn't have permission to write to that location).

5. Use sudo to update a symlink which always points to the latest version of the software (i.e. Remove 'software.zip' which points to software-1.0.zip and then create a link to software-1.1.zip)

6. Use sudo to change the ownership of the new files to the correct owner (apache).

7. Update the web page with the information about the newest version.

This is fairly tedious and I'l like to automate at least some of it. The most annoying part is the permissions on the web directory. What are the recommended options? Here are some of my ideas:

1. Permit remote access using SSH keys as the apache user. Then I can copy the file into the correct location immediately. Then update the link easily. Or I could allow my user to run as apache using sudo.

2. Have some sort of git post-receive hook:

http://stackoverflow.com/questions/3838 … te-staging">http://stackoverflow.com/questions/3838727/git-post-receive-hook-for-website-staging

3. Change the group ownership on /var/www/……… to a group which has both my user and apache as members.

4. Have a cronjob running as apache which looks for files in a directory owned by my user.

Anyone have any good suggestions? Ideally, I'd like to get to the situation where I can run one deploy script on my workstation and it'll deploy the new software release.

Any suggestions/recommendations?

Thanks,

Dan

5 Replies

Here's one of my favourite methods.

1) Have a bare git repo on the server storing the entire code base

2) Push your local changes to this repo

3) Have the web directory pull from this repo

Then to update you simply run git push locally and git pull on the remote to update the web directory, it also makes reverting changes easy since you just run git checkout on the web directory.

As for permissions, run the git pull command as root :)

You can also add a git post commit hook to automatically run git pull each time you push, but I prefere to do this manually.

This is pretty much what I was thinking of, but has the disadvantage that I have to store my packaged software in git - not ideal…

Anyone know how this is solved in companies or big software projects?

We use Fabric for deployments. There's literally tons of tutorial for rapid web deployment using Fabric if you google a little.

Excellent, I hadn't found that tool before. Thanks.

I use a combination of mcollective and puppi for actual deployment, and use jenkins to manage dev->stage->prod workflow and testing

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct