Set up version control of local files with the help of nginx server

Ian Hobson hobson42 at gmail.com
Sat Oct 31 10:51:05 UTC 2015


Hi,

I have had a lot of success with using git and nginx, with rsync to 
update the files.

Set up two servers: "live" out on the internet and "staging" on your 
local kit. On staging create a directory to store your website, and
create htdocs within it.

Then you can also create a configs directory to contain your 
configuration files, and symlink to them from their normal location. For 
example you might symlink your domain's nginx configuration from
/etc/nginx/sites-enabled/nginx-domain.conf and point it at 
configs/nginx-domain.conf in your repository.

In this manner you can place all the software on your web site under 
version control.

When you have completed an update, and all is working on your staging 
server, you run a script that calls rsync to copy all changes to the 
live server and restart any programs necessary (nginx, uwsgi).

That way, the script runs quickly and accurately, while rsync ensures 
that all changes are included. Your release is quick and your changes 
can be fully tested on staging before they go out.

If there is a database to copy, this is included in your script. Even a 
dump/rsync/restore tends to be remarkably quick.

With all the files under git version control, you can develop where-ever 
you (or your assistants) want, and assemble the changes on staging. 
Another advantage of git is that everyone has the complete history of 
all changes, so further backups may not be necessary.

bitbucket.org offer git hosting for free for small groups. I use them as 
the "origin" repo for all users.

Ian

On 31/10/2015 08:40, Francis Daly wrote:
> On Tue, Oct 20, 2015 at 08:41:38PM +0200, Tie Cheng wrote:
>
> Hi there,
>
>> I have bought a dedicated server from DigitalOcean, and configured nginx.
>>
>> I want to version control my local files, and I am wondering if I could
>> commit and update them from time to time to this server.
>
> nginx is a web server.
>
> version control is independent of a web server.
>
> So you should be able to pick whatever version control system you want,
> and if it provides a web interface, reverse proxy to that through nginx.
>
> But the web interface may not provide all the version control
> facilities. And if it uses more than GET and POST (DAV parts, for
> example), it may be more tricky.
>
>> It seems that the setup is not straightforward (some posts say that we have
>> to use Apache for svn). I don't mind if it is svn or git, I just want to
>> follow an easy approach.
>
> I would suggest: first pick the version control system that you want to use.
>
> Then search for "that and nginx" to see if there is a recipe that someone
> else says works.
>
>> Could any one help?
>
> I could say "use fossil in scgi mode"; but if you have reasons to prefer
> svn, then that wouldn't be helpful.
>
> Cheers,
>
> 	f
>

-- 
Ian Hobson
Preparing ebooks for the Kindle to give the best possible reader 
experience.
Tel 020 3287 1392



More information about the nginx mailing list