Introduction: Drupal 8 Version Control & Subversion (SVN)
This Tutorial will show how to transfer a Drupal 8 website from a localhost environment running WampServer to a remote hosting platform using Subversion (SVN) for version control. Subversion (SVN) is an alternative to Git & CVS that is used in Agile teams.
Drupal 8 developers can install the CMS locally in a development environment with a choice of MySQL,PostgreSQL, or MariaDB by default using WampServer.
Subversion (SVN) is used to upload files to a remote sandbox, to a code repository, & production site using this guide with instructions also on theme & module management.
Step One: Install SVN in the Drupal 8 Development Pipeline
In order to be effective as a Version Control standard for Drupal 8 development, Subversion (SVN) must be installed on the desktop/laptop workstations of programmers as well as on the web servers that host the files. A professional option is:
- CloudForge: combines project management & version control tools.
Without a platform utility, SVN can be installed on localhost web servers running Drupal 8 such as WampServer, VirtualBox, Docker Desktop, XAMPP, or Apache Netbeans.
Required Files – Download:
- CollabNet Subversion: (Download Files)
- Apache Subversion: (Download Files)
CollabNet also has Subversion distributions available that integrate with the Eclipse & Visual Studio developer suites. Professional license are around $2 per user per month.
In order to synchronize with programmer workstations for version control, Subversion must be installed on the web server. Many teams use a development subdomain.
Set up a dev subdomain for staging, sandboxing, & code testing at dev.yourdomain.com which will function as the central repository for all Agile team code changes pushed.
Clone the files from the production site to the dev subdomain & use the zip/gzip files to distribute a standardized version of the Drupal 8 base installation with MySQL file.
Using Sudo on Ubuntu, CentOS, RHEL, etc. run the following command:
sudo apt-get install subversion-tools
On Gentoo, ChromeOS, & other Linux OS servers running Portage:
emerge subversion
or
emerge -av subversion
Next, set a path to a folder for SVN to use as a cache file on transfers:
my $svn = '/usr/bin/svn';
Otherwise, with Portage, run:
emerge --config dev-util/subversion
Then run the following two commands to copy files to the directory:
sudo cp svn_load_dirs.pl.in /usr/bin/svn_load_dirs sudo cp svnmerge.py /usr/bin/svnmerge
After this, Subversion will be successfully installed & configured for use with Version Control software. Subversion can also be used to download Drupal 8 core, modules, & themes using the command line utilities packaged on an Apache web server.
Step Two: Use Subversion to Install Drupal 8 Core Files
After installing Subversion & configuring the main repository path, the command line can be used to download & install Drupal 8 core files, similar to Drush or Composer.
Create a temporary folder & use wget to download the latest Drupal 8 files:
$cd /tmp $ wget https://ftp.drupal.org/files/projects/drupal-8.6.3.tar.gz $ tar xzf drupal-8.6.3.tar.gz
Open phpMyAdmin & create a new MySQL database for the Drupal 8 installation. Give the database a unique name, password, & user with all permissions.
Copy the database from a local development environment to the subdomain to create the staging environment using the Backup & Migrate module to port the files (link).
Step Three: Create a New Project on Development Server
On the staging subdomain or a local development environment, Subversion can be used to create a new project from the production server files of the Drupal 8 installation.
First, create a new project in a tmp directory with a unique branch tag in the trunk:
mkdir -p ~/svn-import/{branches,tags,trunk}Next, populate the directory by copying all of the source files into the trunk folder:
cp -R /my/path/to/project/* ~/svn-import/trunk
Finally, import the project directly from the source files:
svn import -m "Development server" ~/svn-import https://example.com/svn/REPO_NAME/
Using these commands with Subversion, the time required in creating new Drupal 8 development environments across multi-cloud or hybrid cloud hardware completes in seconds. The file transfers can be expedited by zip/gzip transfers to local workstations.
Step Four: Configuring the Apache Web Server Files & SSL
Review the settings on the Apache server files for Subversion. In the httpd.conf file located at: /etc/httpd/conf/httpd.conf make sure all of the values below are listed:
LoadModule dav_module modules/mod_dav.so LoadModule dav_fs_module modules/mod_dav_fs.so LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so
Next use the Apache AuthType Basic standard to generate a SSL Certificate for Subversion to use on file transfers & team communications:
#cd /etc/httpd/conf/ # openssl req -new -x509 -keyout server.key -out server.crt -days 365 -nodes
Add a Virtual Host Directive to: /etc/httpd/conf/extra/httpd-ssl.conf (or use: /etc/httpd/conf/extra/httpd-vhosts.conf if no SSL required):
<Location /svn> DAV svn SVNParentPath /home/svn/repositories AuthzSVNAccessFile /home/svn/.svn-policy-file AuthName "SVN Repositories" AuthType Basic AuthUserFile /home/svn/.svn-auth-file Require valid-user </Location>
Finally, edit the httpd.conf file to read:
LoadModule ssl_module modules/mod_ssl.so LoadModule socache_shmcb_module modules/mod_socache_shmcb.so Include /etc/httpd/conf/extra/httpd-ssl.conf
The Apache web server will now be configured to support Subversion for version control requirements across the software production lifechain. Drupal 8 administrators can also consider using project management tools like CloudForge, Netbeans, or Eclipse for more efficient integration of Subversion across multi-cloud environments.
Step Five: Other Important Subversion Commands
There are many more powerful commands for using Subversion to manage a Drupal 8 website or server, i.e. via CLI utilities like PuTTY, SSH, Bash Scripts, & Shell Access.
Create a new directory for SVN repos:
mkdir -p /home/svn/repositories
Making a diff file analysis:
svn diff
or
svn diff path/to/sites/all/modules/project/file.ext
Apply a diff line conversion through new patch file:
patch -p0 < patch/path/to/file
SVN Ignore files:
svnpropeditsvn:ignore mydirectory
Delete:
svn delete file.name
Move:
svn mv file1 file2
Revert:
svn revert file.name
Status:
svn status
Commit:
svn commit
Update:
svn update
For more information on using Subversion for Version Control & Drupal 8 development, see the following resources:
- Version Control with Subversion
- Apache Subversion User Manual
- ArchLinux Subversion Guide
- Gentoo Subversion Basics
- Drupal & Subversion
Subversion (SVN) has become a global web standard for Version Control in software development teams, especially for web & mobile apps under Agile/Scrum methodology.
Conclusion: Feature-Rich SVN Version Control vs. Git
Subversion is a powerful command line utility for version control across programming teams on Linux, Mac, & Windows, but is widely being surpassed by Git in practice.
While some teams may still be using Subversion in professional environments for Drupal 8 development, most are recommended to use Git over SVN for new projects.
Topics:Drupal 8, WampServer, Subversion, Version Control, Agile, Web Development
Level:Intermediate
Time:10 minutes
- Want to get top recommendations about best hosting? Just click this link!
