Voici mes anciennes notes sur l'installation et config de SVN pour le web. L'idee est de creer un repository qui actualise a chaque modification un serveur web, et permet ainsi d'avoir les avantages de SVN sans avoir a faire de "commit" a chaque petite modification.
1)-------SVN Install:
==============================
(apache2 and mod_dav needs to be already installed)
--> First need to install SVN
# yum install svn ( or check on the web for how to get subversion)
# yum install mod_dav_svn ( and mod_dav if mod_dav not yet installed)
--> configure mod_dav to interact with svn
open subversion.conf (in Fedora, it is located at /etc/httpd/conf.d/subversion.
Add the following :
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /var/www/svn/users/passwords
Require valid-user
DAV svn
SVNParentPath /usr/local/svn
This will link the web directory /svn/repos ( http://host_address/svn/repos) to the
SVN directory located at the following path: /var/www/svn/repos
The AUTH lines, tells apache to launch an authenticate box to prevent anybody from
accessing http://host_address/svn/repos
it will look for the users and passwords in the file "passwords"
To prepare this file, CD to /var/www/svn/users/
# htpasswd -cm passwords gbelbe (htpassword file_name user_name)
(then to add new accounts don't forget to do htpasswd -m and not -cm)
==============================
Subversion software should be installed and working
==============================
2)----SVN Setup
==============================
Note on repositories organization:
------------------------------
We need to create 3 distinct SVN Repos to make it easier to
upgrade from Dev server to test server and production server.
1 for Development[gdm], 1 for Documentation[gdm_doc], 1 for test[gdm_test]
When we want to upgrade our test or production server, we will only
update the application data (gdm repository) to the web serverm,
We don't need to update test and doc repository (and shouldn't for security purposes)
so it's better practice to keep them in distinct repositories.
Note: as for the SQL data, it's better to keep it included into the dev repository,
as we need to record all change in db structure with DDL scripts at the same "time"
(the same revision nr or version) as we make modification on the system, it will help
to keep track of the database modifications at each step of the software version.
SVN Repositories placed at /var/www/svn/repos
=================
1) first repos for system development: gdm
we change working directory to /var/www/svn/repos
# cd /var/www/svn/repos
we create a svn repository
# svnadmin create gdm
(to remove a repository, only delete it) # rm -Rf gdm
we ensure that the owner and group of this repository is apache:
ls -la
chown -Rf apache.apache gdm
we create a repository structure:
# mkdir /tmp/gdm
# mkdir /tmp/gdm/trunk
# mkdir /tmp/gdm/branches
# mkdir /tmp/gdm/tags
we import this structure:
# svn import /tmp/gdm http://localhost/svn/repos/gdm
===================
The SVN Directory is ready to use, we need to prepare working copies
===================
then create a working directory inside the webserver served directory
in our setup, apache is configured to serve files under /var/www/html
on se positionne ds le rep html #
# cd /var/www/html
on checkout le repository gdm
# svn checkout file:///var/www/svn/repos/gdm/
(this will checkout only the trunk to a new folder named "gdm")
be sure to change the ownership rights to apache user and group
chown -Rf apache.apache gdm
=====================
1) automatic update of website checkout
Note : only needs to be done if the repository is a development server.
If the svn repository is for a Development website,
we can automatically update the website Checkout each time
anyone commit a file. (that way the developpers can view the result
of their work on the local website)
this is done through a post-commit script:
cd to the svn repository:
cd /var/www/svn/repos/
cd hooks
copy the file post-commit.tpl to post-commit
edit the file post-commit with vi:
add the following lines after the line #!/bin/sh
(note: /var/www/html/gdm is the dir where gdm repository will be served by apache)
cd /var/www/html/gdm
/usr/bin/svn up --username apache --password apache
* make sure the post-commit file is owned by apache,
* give the file execution rights
* make sure the directory in the web server is created /var/www/html/gdm
chmod 0777 post-commit
chown apache.apache post-commit
Test: try to modify a file in this repository from your computer and commit,
check if the file is updated on the webserver.
==> check the ownership of the files (it should be apache.apache)
Commentaires
Enregistrer un commentaire
Tell me what you think