Prerequisites for apache2 : - php - libapache2-mod-php
You can install those packages running :
sudo apt install php libapache2-mod-php
.
Then enable the package :
sudo a2enmod php8.3
(tune version name, you can usephp -v
to see which version is installed).
Restart apache :sudo systemctl restart apache2
.
Clone websvn repo (release 2.8.4) in /var/www/ :
sudo git clone --branch 2.8.4 https://github.com/websvnphp/websvn.git
Create a new apache2 config file in /etc/apache2/conf-available/websvn.conf
sudo nano /etc/apache2/conf-available/websvn.conf
Content is set to :
Alias /websvn /var/www/websvn
<Directory /var/www/websvn>
DirectoryIndex index.php
Options FollowSymLinks
</Directory>
Note : If you cloned websvn.git in another directory, change the Alias directive and
<Directory>
paths accordingly !
Then we enable our newly created websbn configuration file using a2enconf (a
pache2
en
ableconf
):
sudo a2enconf websvn
Restart apache2
sudo systemctl restart apache2
Now that necessary modules have loaded in apache2 with the websvn php project has been cloned, you can navigate to <your IP or domain>/websvn
to discover a magnificent message displayed on your browser:
No config applied, either create "include/config.php" or use environment variable "WEBSVN_PATH_CONF". The example file "include/distconfig.php" should be copied and modified as needed.
We have two options to store the config.php
file in our system. The simplest is to create this config file in the include
directory of websvn php filesystem installation (where index.php lives).
The second option is to create an envirement variable named WEBSVN_PATH_CONF
that points to the config.php
file in your custom directory.
We will use the first option, start by copying the example config file <websvn_root>/include/distconfig.php
to config.php
:
# <websvn_root> example : /var/www/websvn
cd <websvn_root>/include/
sudo cp distconfig.php config.php
# The following line removes all comments in the file
sudo sed -i '/^\/\//d;/^$/d' config.php
Edit the config file and append the following lines to tell websvn where to find the sed and encrypt commands executables along with the parent path of our repositories (here assumed to be /var/svn
) :
// CLI tools
$config->setEnscriptPath('/usr/bin');
$config->setSedPath('/bin');
// $config->addRepository(...) to add repositories one-by-one, or
// $config->parentPath(...) to add a directory full of repositories at once.
$config->parentPath('/var/svn');
$config->useEnscript();
What the hell is enscript ? Well, basically, it does code highlighting among other things
You may not have enscript installed on your system, and see an error on your browser in that regard.
To install enscript, run:
sudo apt install enscript
This should have installed the enscript executable in/usr/bin/enscript
. You can check the actual install path by typing :which enscript
$config->addRepository
directive ://$config->addRepository('NameToDisplay', 'local URL');
//$config->addRepository('NameToDisplay', 'local URL', 'group');
//example config :
?php
<$config->addTemplatePath($locwebsvnreal.'/templates/calm/');
$config->addTemplatePath($locwebsvnreal.'/templates/BlueGrey/');
$config->addTemplatePath($locwebsvnreal.'/templates/Elegant/');
$config->addInlineMimeType('text/plain');
$config->setMinDownloadLevel(2);
set_time_limit(0);
$config->expandTabsBy(8);
// Syntax highlighting
$config->setEnscriptPath('/usr/bin');
$config->setSedPath('/bin');
$config->useEnscript();
// Available repos
$config->addRepository('My project A in group 1', 'file://</path/to/repo/>', 'Group1');
$config->addRepository('My project A in group 2', 'file://</path/to/repo/>', 'Group2');
$config->addRepository('My project B in group 2', 'file://</path/to/repo/>', 'Group2');
// Use tree index to able expand/collapse of the repo groups
$config->useTreeIndex(true);
// Block web scrapping bots to eat the data, also avoids the page to get referenced by search engines
$config->setBlockRobots();
You can edit the greeting message of websvn by customizing the <websvn_root>/templates/<your_template>/user_greeting.tmpl
file. <your_template>
can be for example the built in calm template. The templates folder should at least contain the basic templates provided by default :
<websvn_root>/templates
├── BlueGrey
├── Elegant
└── calm