Wednesday, July 9, 2014

Bugzilla on Windows 2008 & Oracle 11g

Having found absolutely NO correct documentation on how to install Bugzilla on Windows Server 2008 64-bit and Oracle 11g, I thought I'd publish the results of many days of research. As with many open source projects, it's free only if your time is worth nothing, and it's held together by spit.

I'm providing the condensed version of steps to implement.

Software Prerequisites / Assumptions:

1. Oracle 11.2.0.4 64-bit for Windows
2. Apache installer, httpd-2.2.25-win32-x86-openssl-0.9.8y.msi
3. Perl 32-bit. ActivePerl-5.16.3.1604-MSWin32-x86-298023.msi

Yes, on Windows 2008 64-bit you NEED 32-bit Perl from Activestate. Strawberry Perl doesn't work with Oracle (there's no Oracle DBD or so).

4. Bugzilla. bugzilla-4.4.4.tar.gz
5. Oracle Instantclient, instantclient-basic-nt-11.2.0.4.0.zip

Steps:

1. Install Oracle 11g, create a database called bugs.
2. Login as SYS, and create a user called bugs, such as:

create user bugs identified by bugs default tablespace users;
grant connect,resource,unlimited tablespace to bugs;

3. Install Perl. I'm assuming you accept the defaults and the location installed is C:\Perl.
4. Merge this REG file into the registry:

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI\Command]
@="C:\\Perl\\bin\\perl.exe -wT"

[HKEY_CLASSES_ROOT\.pl\Shell\ExecCGI\Command]
@="C:\\Perl\\bin\\perl.exe -wT"

Note: The command parameter is wT

5. Install Apache. Where you install it is up to you, but I would recommend a location without spaces e.g. C:\Apache2

6. Extract the contents of bugzilla-4.4.4.tar.gz to C:\bugzilla, such that C:\bugzilla\checksetup.pl exists.

7. From instantclient-basic-nt-11.2.0.4.0.zip, copy oci.dll and oraociei11.dll to C:\bugzilla

8. In C:\Bugzilla, create the file install-ppms.bat with the following contents:

call ppm install TimeDate
call ppm install DateTime
call ppm install DateTime-TimeZone
call ppm install Template-Toolkit
call ppm install Email-Send
call ppm install Email-MIME
call ppm install Math-Random-ISAAC
call ppm install Chart
call ppm install Template-GD
call ppm install MIME-tools
call ppm install XML-Twig
call ppm install PatchReader
call ppm install perl-ldap
call ppm install Authen-SASL
call ppm install Net-SMTP-SSL
call ppm install RadiusPerl
call ppm install SOAP-Lite
call ppm install XMLRPC-Lite
call ppm install JSON-RPC
call ppm install JSON-XS
call ppm install Test-Taint
call ppm install HTML-Scrubber
call ppm install Encode-Detect
call ppm install Email-Reply
call ppm install HTML-FormatText-WithLinks
call ppm install TheSchwartz
call ppm install Daemon-Generic
call ppm install mod_perl
call ppm install Apache-SizeLimit
call ppm install File-MimeInfo
call ppm install IO-stringy

9. Configure Apache by following these steps:

Stop the Apache service.

Configure Port and DocumentRoot

Edit C:\Apache2\conf\httpd.conf with notepad.
To change the port that Apache runs on (listens on, or binds to), edit the Listen option.
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
#Listen 12.34.56.78:80
Listen 80

Change the DocumentRoot setting to point to C:/Bugzilla. Note there are two locations in httpd.conf that need to be updated. Note you need to use / instead of \ as a path separator.
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#

DocumentRoot "C:/Bugzilla"

#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories). 
#
# First, we configure the "default" to be a very restrictive set of 
# features.  
#
<Directory />
   Options FollowSymLinks
   AllowOverride None
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "C:/Bugzilla">

Configure CGI

To enable CGI support in Apache, you need to enable the CGI handler, by uncommenting the AddHandler cgi-script .cgi line.
#
# 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
And allow .cgi scripts in the Bugzilla directory by adding the ExecCGI option. We also need to allow Bugzilla's .htaccess file to restrict access to sensitive documents by allowing it to override the defaults. This involves changing AllowOverride None to AllowOverride All.
Apache also needs to know to use Perl to execute .cgi files, via the ScriptInterpreterSource directive.
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "C:/Bugzilla">

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs-2.0/mod/core.html#options
# for more information.
#
    Options Indexes FollowSymLinks ExecCGI

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride All

#
# Controls who can get stuff from this server.
#
   Order allow,deny
   Allow from all

#
# Tell Apache to use Perl to execute .cgi
#
    ScriptInterpreterSource Registry-Strict

</Directory>
You also should add index.cgi to the DirectoryIndex list.
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
# The index.html.var file (a type-map) is used to deliver content-
# negotiated documents.  The MultiViews Option can be used for the 
# same purpose, but it is much slower.
#
DirectoryIndex index.html index.html.var index.cgi

Disable Logging
Unless you want to keep statistics on how many hits your Bugzilla install is getting, it's a good idea to disable logging by commenting out the CustomLog directive.
#
# The location and format of the access logfile (Common Logfile Format).
# If you do not define any access logfiles within a <VirtualHost>
# container, they will be logged here.  Contrariwise, if you *do*
# define per-<VirtualHost> access logfiles, transactions will be
# logged therein and *not* in this file.
#
#CustomLog logs/access.log common

Restart Apache

Finally, restart the Apache service.

9. Execute install-ppms.bat:
cd /d c:\bugzilla
C:\bugzilla>install-ppms
This takes a while to run while all the required modules are installed.
10. execute checksetup.pl
C:\bugzilla>perl checksetup.pl
If this succeeds, it should generate a file called localconfig.
11. Configure localconfig
C:\bugzilla>notepad localconfig

Change the following lines:
$db_driver = 'oracle';
$db_host = 'localhost';

$db_name = 'bugs';

$db_user = 'bugs';

$db_pass = 'bugs';

12. Re-run checksetup.pl

C:\bugzilla>perl checksetup.pl

If you're asked for an smtp server, enter 'localhost'; this can be changed later.

When this script completes, that's it, should be sorted.

You can test your bugzilla installation by using:


C:\bugzilla>perl testserver.pl http://localhost
TEST-OK Got padlock picture.
TEST-OK Webserver is executing CGIs via mod_cgi.
TEST-OK Webserver is preventing fetch of http://localhost/localconfig.
TEST-OK GD library generated a good PNG image.
defined(@array) is deprecated at C:/Perl/site/lib/Chart/Base.pm line 181.
        (Maybe you should just omit the defined()?)
defined(@array) is deprecated at C:/Perl/site/lib/Chart/Base.pm line 233.
        (Maybe you should just omit the defined()?)
TEST-OK Chart library generated a good PNG image.
TEST-FAILED Template::Plugin::GD is not installed.

Notice how the last test failed, but Bugzilla still works. The missing plugin must be needed for an optional feature.