# Setting up ViewVC FreeBSD 10.1



## andrewm659 (Mar 27, 2015)

I seem to be having some issues making ViewVC work.  I have setup a vhost using Apache 2.4, but I can't access it.  I'm not sure what I'm missing. I'm still new to FreeBSD 10.1.

Here is my current config of /usr/local/etc/apache24/extra/httpd-vhosts.conf


```
<VirtualHost *:80>
DocumentRoot "/usr/local/viewvc/bin"
ScriptAlias /cgi-bin/ "/usr/local/viewvc/bin/cgi-bin/"
ScriptAlias /viewvc /usr/local/viewvc/bin/cgi-bin/viewvc.cgi
ScriptAlias /query /usr/local/viewvc/bin/cgi-bin/query.cgi
Alias /viewvc "/usr/local/viewvc/bin/cgi/"
<Directory "/usr/local/viewvc/bin/cgi">
    AddHandler cgi-script .cgi
    Options NONE +ExecCGI
    DirectoryIndex /viewvc/viewvc.cgi
    Order allow,deny
    Allow from all
    Require all granted
</Directory>
</VirtualHost>
```

Log output

```
[Fri Mar 27 12:02:12.979488 2015] [mpm_prefork:notice] [pid 26034] AH00169: caught SIGTERM, shutting down
[Fri Mar 27 12:02:13.161549 2015] [mpm_prefork:notice] [pid 26165] AH00163: Apache/2.4.12 (FreeBSD) configured -- resuming normal operations
[Fri Mar 27 12:02:13.161974 2015] [core:notice] [pid 26165] AH00094: Command line: '/usr/local/sbin/httpd -D NOHTTPACCEPT'
[Fri Mar 27 12:02:16.420596 2015] [authz_core:error] [pid 26167] [client 10.150.1.99:56408] AH01630: client denied by server configuration: /usr/local/viewvc/bin/cgi-bin
root@tsg-monitoring01:/usr/local/etc/apache24/extra #
```

This is somewhat out of order.


```
<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig etc/apache24/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    #AddType text/html .shtml
    #AddOutputFilter INCLUDES .shtml
</IfModule>

# Fancy directory listings
Include etc/apache24/extra/httpd-autoindex.conf

# Real-time info on requests and configuration
Include etc/apache24/extra/httpd-info.conf

# Virtual hosts
Include etc/apache24/extra/httpd-vhosts.conf

<IfModule dir_module>
    DirectoryIndex index.html index.htm index.php
</IfModule>
```


----------



## acheron (Mar 27, 2015)

Check this out: http://httpd.apache.org/docs/2.4/upgrading.html#access


----------



## andrewm659 (Mar 27, 2015)

thank you


----------



## andrewm659 (Mar 27, 2015)

ok made changes to vhosts config, still the same thing...


```
<VirtualHost *:80>
DocumentRoot "/usr/local/viewvc/bin"
ScriptAlias /cgi-bin/ "/usr/local/viewvc/bin/cgi-bin/"
ScriptAlias /viewvc /usr/local/viewvc/bin/cgi-bin/viewvc.cgi
ScriptAlias /query /usr/local/viewvc/bin/cgi-bin/query.cgi
Alias /viewvc "/usr/local/viewvc/bin/cgi/"
<Directory "/usr/local/viewvc/bin/cgi">
    AddHandler cgi-script .cgi
    Options NONE +ExecCGI
    DirectoryIndex /viewvc/viewvc.cgi
    Require all granted
</Directory>
</VirtualHost>
```



```
[Fri Mar 27 14:48:35.641148 2015] [core:notice] [pid 26953] AH00094: Command line: '/usr/local/sbin/httpd -D NOHTTPACCEPT'
[Fri Mar 27 14:48:40.329998 2015] [authz_core:error] [pid 26955] [client 10.150.1.99:56457] AH01630: client denied by server configuration: /usr/local/viewvc/bin/cgi-bin
[Fri Mar 27 14:48:42.550334 2015] [authz_core:error] [pid 26955] [client 10.150.1.99:56457] AH01630: client denied by server configuration: /usr/local/viewvc/bin/cgi-bin
[Fri Mar 27 14:48:43.114061 2015] [authz_core:error] [pid 26955] [client 10.150.1.99:56457] AH01630: client denied by server configuration: /usr/local/viewvc/bin/cgi-bin
[Fri Mar 27 14:48:43.430786 2015] [authz_core:error] [pid 26955] [client 10.150.1.99:56457] AH01630: client denied by server configuration: /usr/local/viewvc/bin/cgi-bin
[Fri Mar 27 14:48:43.661509 2015] [authz_core:error] [pid 26955] [client 10.150.1.99:56457] AH01630: client denied by server configuration: /usr/local/viewvc/bin/cgi-bin
[Fri Mar 27 14:48:44.667015 2015] [authz_core:error] [pid 26954] [client 10.150.1.99:56458] AH01630: client denied by server configuration: /usr/local/viewvc/bin/cgi-bin
[Fri Mar 27 14:49:41.281160 2015] [authz_core:error] [pid 26957] [client 10.150.1.54:22150] AH01630: client denied by server configuration: /usr/local/viewvc/bin/
[Fri Mar 27 14:49:42.457532 2015] [authz_core:error] [pid 26957] [client 10.150.1.54:22150] AH01630: client denied by server configuration: /usr/local/viewvc/bin/favicon.ico
[Fri Mar 27 14:49:42.898791 2015] [authz_core:error] [pid 26957] [client 10.150.1.54:22150] AH01630: client denied by server configuration: /usr/local/viewvc/bin/favicon.ico
root@tsg-monitoring01:/usr/local/etc/apache24 #
```


----------



## andrewm659 (Mar 27, 2015)

Here's more


```
[Fri Mar 27 16:33:30.997160 2015] [mpm_prefork:notice] [pid 1009] AH00169: caught SIGTERM, shutting down
[Fri Mar 27 16:33:31.194962 2015] [mpm_prefork:notice] [pid 1056] AH00163: Apache/2.4.12 (FreeBSD) configured -- resuming normal operations
[Fri Mar 27 16:33:31.195423 2015] [core:notice] [pid 1056] AH00094: Command line: '/usr/local/sbin/httpd'
[Fri Mar 27 16:33:38.119618 2015] [authz_core:error] [pid 1058] [client 10.150.1.99:56520] AH01630: client denied by server configuration: /usr/local/viewvc/bin/index.php
[Fri Mar 27 16:34:03.474514 2015] [authz_core:error] [pid 1060] [client 127.0.0.1:46472] AH01630: client denied by server configuration: /usr/local/viewvc/bin/
```


----------



## vr0 (Apr 25, 2015)

Hello andrewm659,

Test this:


```
<VirtualHost *:80>
ScriptAlias /viewvc /usr/local/viewvc/bin/cgi/viewvc.cgi
<Directory "/usr/local/viewvc/bin/cgi">
  AddHandler cgi-script .cgi
  Options NONE +ExecCGI
  DirectoryIndex viewvc.cgi
  Require all granted
</Directory>
</VirtualHost>
```


----------



## andrewm659 (Apr 27, 2015)

I got it working.  Sorry I didn't mention this before.  Took a lot of hacking learned a lot.  But thank you!


----------



## dvl@ (Nov 22, 2016)

Here I am, with the same problem, wishing that the OP had posted the solution... :/


----------



## SirDice (Nov 22, 2016)

Looking at the OP's configuration, there's a ScriptAlias pointing to /usr/local/viewvc/bin/cgi-bin/ but there's no Directory statements that allow access to that directory.

I also see two different references, /usr/local/viewvc/bin/cgi/ and /usr/local/viewvc/bin/cgi-bin. One of them is probably wrong.

There's also two different access styles:

```
Order allow,deny
    Allow from all
    Require all granted
```
The first two are for Apache 2.2. The third is for Apache 2.4. Having them both is probably going to cause issues.


----------



## andrewm659 (Nov 22, 2016)

I'm more than happy to post my fix and or solution.  I've documented it.


----------



## dvl@ (Nov 26, 2016)

andrewm659 said:


> I'm more than happy to post my fix and or solution.  I've documented it.



Please post.  I've solved my issue now, but others will follow.


----------



## andrewm659 (Dec 7, 2016)

dvl@ said:


> Please post.  I've solved my issue now, but others will follow.


Will do.  Sorry, been busy.  But I'll clean up the instructions.


----------



## Oko (Dec 7, 2016)

I have being running ViewVC in production for several years of OpenBSD 5.5 (didn't bother to upgrade as I was hopping to kill CVS and SVN in favor of Git/Gogs). OpenBSD was using build in version of Apache 1.3. This is fully functional httpd.conf  file which I started using after realizing that ViewVC is shipped with build in Pyhton web server which suffers from memory leak (we were able to crash it at will). It was not very difficult and there are multiple ways to use ViewVC with Apache I forgot what made me do this particular way.

http://www.cs.cmu.edu/afs/cs/user/predragp/www/httpd.conf

Note that I never got server to work as chroot so I used so called insecure mode (in OpenBSD lingo) which is not the problem for FreeBSD. I am guessing one would have to be careful with the configuration file as configuration options have changed between 1.xxx and 2.xxx version of Apache but it will give you a good start.


----------



## andrewm659 (Dec 12, 2016)

Here are the instructions I put together.  Let me know if you run into problems.

Hope this helps!



```
1.  Install ViewVC from pkg repo & take all the dependencies
pkg install viewvc ap24-mod_fastcgi-2.4.7_1 ap24-mod_fcgid-2.3.9 apache24

 mod_php56-5.6.6 php5-mysql-5.4.38 (php53-mysql-5.3.29_4, php55-mysql-5.5.22, php56-mysql-5.6.6) php5-simplexml-5.4.38 php5-xml-5.4.38 (php53-simplexml-5.3.29_4 php53-xml-5.3.29_4 php55-xml-5.5.22 php55-xmlreader-5.5.22 php56-xml-5.6.6 php56-xmlreader-5.6.6) py27-mysql-connector-python-1.2.3 or py27-mysql-connector-python2-2.0.3 p5-GD-2.56_2 php56-gd-5.6.6 ( php55-gd-5.5.22 php53-gd-5.3.29_5 php5-gd-5.4.38)

2.  Enable Apache to run on startup
echo 'apache24_enable="YES"' >> /etc/rc.conf

3.  Setup ViewVC to work with Apache by adding a virtualhost
vi /usr/local/etc/apache24/Includes/viewvc.conf

Comment out all the example entries and add the following:

<VirtualHost *:80>
 Alias /viewvc "/usr/local/viewvc/bin/cgi/"
<Directory "/usr/local/viewvc/bin/cgi">
    AddHandler cgi-script .cgi
    Options +ExecCGI +FollowSymlinks
    DirectoryIndex viewvc.cgi
    Require all granted
</Directory>
</VirtualHost>

4.  Edit the /usr/local/etc/apache24/httpd.conf and uncomment the following
vim /usr/local/etc/apache24/httpd.conf

Set the hostname:
ServerName FQDN

Line 162 or 159
Uncomment the following
<IfModule mpm_prefork_module>
        LoadModule cgi_module libexec/apache24/mod_cgi.so
</IfModule>

Uncomment on line 494
# Virtual hosts
Include etc/apache24/extra/httpd-vhosts.conf

5.  Make sure that /usr/local/viewvc/bin/cgi/*.cgi files are owned by www:www and are 755
cd /usr/local/viewvc/bin/cgi/
chown www:www *
chmod 755 *

6.  Edit the ViewVC config and go to the bottom of the general section (do the salute)
vi /usr/local/viewvc/viewvc.conf
:260
Insert the following

[general]
root_parents = /usr/local/var/rancid/CVS : cvs
rcs_path = /usr/bin/
use_enscript = 1
enscript_path = /usr/bin/
use_highlight = 1
highlight_path = /usr/bin

Esc
:wq!

7.  Restart Apache and try to browse to the web location
sudo service apache24 onerestart
```


----------



## ohauer (Jan 6, 2017)

Hm, the ViewVC package shows a sample configuration for apache and lighttpd during installation (pkg-message) that can be displayed later also with the command `pkg info -D viewvc`
For apache most all restrictions from <Directory ...> can be set also in the <Location ...> section so taking the example code before this should work.


```
<VirtualHost *:80>
    ServerName my.host.name

    <IfModule wsgi_module>
        ## viewvc fix
        WSGIRestrictSignal Off
    </IfModule>

    RewriteCond %{REQUEST_URI} ^/viewvc$
    RewriteRule ^(/viewvc)$    $1/ [R=301,L]

    <IfModule !wsgi_module>
        AddHandler cgi-script .cgi
        ScriptAlias "/viewvc" "/usr/local/viewvc/bin/cgi/viewvc.cgi"
    </IfModule>

    <IfModule wsgi_module>
        WSGIScriptAlias /viewvc "/usr/local/viewvc/bin/wsgi/viewvc.wsgi"
    </IfModule>


## only required to setup restricition
##
#   <Location /viewvc>
#      SetEnv VIEWVC_CONF_PATHNAME  "/usr/local/viewvc/viewvc-svn.conf"
#       AuthName ...
#       AuthType ...
#       AuthUserFile ...
#       Require valid-user
#   </Location>
</VirtualHost>
```


----------



## dvl@ (May 19, 2018)

Please start a new thread.


----------

