Setting Up SVN on a Linux Server for Remote Code Editing and Automatic Deployment
This guide explains how to install and configure Subversion (SVN) on a CentOS server, create a repository, set up authentication, connect clients, and implement a post‑commit hook that automatically updates the web directory, enabling code editing from devices like an iPad.
Many developers need to modify code while traveling, and using a remote Linux server with SVN allows editing without carrying a laptop.
1. Install SVN on CentOS using the package manager:
<code>yum -y install subversion</code>2. Create the repository directory and start the svnserve daemon:
<code>mkdir /www/svndata</code>
<code>svnserve -d -r /www/svndata</code>3. Create an SVN project and configure it:
<code>svnadmin create /www/svndata/www.ouyangke.cn</code>Edit svnserve.conf (located in the conf folder) and add:
<code>anon-access=none</code>
<code>auth-access=write</code>
<code>password-db=passwd</code>Configure the passwd file with a user account:
<code>ouyangke=ou123</code>4. Client connection can be done with a checkout command such as:
<code>svn checkout svn://localhost/www.ouyangke.cn /www/wwwroot/www.ouyangke.cn</code>5. Automatic synchronization is achieved by creating a post‑commit hook script. Copy the template and edit post-commit :
<code>vi post-commit</code>
<code>REPOS="$1" REV="$2"</code>
<code>BASEPATH=/www/wwwroot/</code>
<code>WEBPATH="$BASEPATH/"</code>
<code>export LANG=zh_CN.UTF-8</code>
<code>svn update $WEBPATH --username ouyangke --password ou123 --no-auth-cache</code>Make the script executable and restart the daemon:
<code>chmod +x post-commit</code>
<code>killall svnserve</code>
<code>svnserve -d -r /www/svndata</code>6. Using Baota panel to edit the project: checkout the repository to an edit directory, update, add new files, and commit changes, e.g.:
<code>svn checkout svn://localhost/www.ouyangke.cn /www/wwwroot/www.ouyangke.cn.edit</code>
<code>svn update</code>
<code>svn add filename</code>
<code>svn commit -m "message" filename</code>If the commit fails, set the editor environment variable:
<code>export SVN_EDITOR=vim</code>After configuration, the project can be accessed via a domain name, allowing code editing from an iPad or other devices at any time.
php中文网 Courses
php中文网's platform for the latest courses and technical articles, helping PHP learners advance quickly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.