Bugzilla:Installation with nginx

From MozillaWiki
Jump to: navigation, search

Note: these instructions are assuming a base OS : CentOS 6.4 (64bit). A good portion can be automated using puppet or chef.

Installing the fcgi stack

Installing fcgiwrap

See more info here [1].

First install the development packages needed (YMMV).

$ yum install automake fcgi-devel

This worked for me (YMMV):

$ cd /tmp
$ [ -d fcgiwrap ] || git clone git://github.com/gnosek/fcgiwrap.git
$ cd fcgiwrap
$ autoreconf -i
$ ./configure
$ make
$ make install
$ cd /tmp
$ rm -rf /tmp/fcgiwrap

Installing spawn-fcgi

This will install the process that forks fcgi processes on demand.

$ yum install spawn-fcgi

Since this usually is configured for apache, we need to edit the configuration for supporting nginx instead.

# /etc/sysconfig/spawn-fcgi
FCGI_SOCKET=/var/run/fcgiwrap.sock
FCGI_PROGRAM=/usr/local/sbin/fcgiwrap
FCGI_USER=nginx
FCGI_GROUP=nginx
FCGI_EXTRA_OPTIONS="-M 0700"
OPTIONS="-u $FCGI_USER -g $FCGI_GROUP -s $FCGI_SOCKET -S $FCGI_EXTRA_OPTIONS -F 1 -P /var/run/spawn-fcgi.pid -- $FCGI_PROGRAM"

Please note that this is referencing fcgiwrap.

Installing nginx

This will install the basic webserver.

$ yum install nginx

Here is an example configuration, assuming the code is placed under /opt/nginx/bugzilla.

# /etc/nginx/conf.d/bugzilla.conf
server {
    listen         80;
    server_name  server.example.com;
    add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
    return 301 https://$host$request_uri;
}

server {
    listen      443 ssl;
    server_name  server.example.com;

    keepalive_timeout    70;
    ssl_session_timeout  10m;
    ssl_session_cache    shared:SSL:10m;

    ssl_certificate      /etc/ssl/certs/server.crt;
    ssl_certificate_key  /etc/ssl/certs/server.key;
    ssl_prefer_server_ciphers   on;

    charset utf-8;

    root       /opt/nginx/bugzilla/;
    index      index.cgi;

    location ~ ^.*\.cgi$ {
        fastcgi_pass  unix:/var/run/fcgiwrap.sock;
        fastcgi_index index.cgi;
        fastcgi_param SCRIPT_FILENAME /opt/nginx/bugzilla/$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }
}

Installing bugzilla

Getting bugzilla code

Using git clone...

$ mkdir -p /opt/nginx && cd /opt/nginx
$ git clone --depth 1 --branch 4.4 https://github.com/bugzilla/bugzilla.git

Or untaring a specific release archive file.

$ # code is mirrored on github - please visit https://github.com/bugzilla/bugzilla/releases for other version
$ wget https://github.com/bugzilla/bugzilla/archive/bugzilla-4.4.2.tar.gz

Installing perl modules

These modules are available on my system, and for those that are available, I prefer to install them globally.

yum install -y perl-GD
yum install -y perl-Chart
yum install -y perl-Template-GD
yum install -y perl-GDTextUtil
yum install -y perl-GDGraph
yum install -y perl-MIME-tools
yum install -y perl-libwww-perl
yum install -y perl-XML-Twig
yum install -y perl-PatchReader
yum install -y perl-LDAP
yum install -y perl-Authen-SASL
yum install -y perl-Net-SMTP-SSL
yum install -y perl-SOAP-Lite
yum install -y perl-JSON
yum install -y perl-JSON-XS
yum install -y perl-Test-Taint
yum install -y perl-HTML-Parser
yum install -y perl-HTML-Scrubber
yum install -y perl-Encode-Detect
yum install -y perl-Email-Reply
yum install -y perl-HTML-Format
yum install -y perl-IO-stringy
yum install -y perl-Class-DBI-Pg
yum install -y perl-Class-DBI-mysql
yum install -y perl-DateTime
yum install -y perl-DBI
yum install -y perl-Email-Send
yum install -y perl-Email-MIME
yum install -y perl-URI
yum install -y perl-List-MoreUtils

Installing modules not available on my system

There were some modules whose versions were not released for my system. For those, I had to installed them under the bugzilla/lib directory using the install-module.pl script.

#!/bin/bash
# installs modules whose versions are not available through yum.
set -e

# required modules
/usr/bin/perl install-module.pl Date::Format
/usr/bin/perl install-module.pl Email::MIME
/usr/bin/perl install-module.pl List::MoreUtils
/usr/bin/perl install-module.pl Math::Random::ISAAC

# optional modules
/usr/bin/perl install-module.pl PatchReader
/usr/bin/perl install-module.pl SOAP::Lite
/usr/bin/perl install-module.pl XMLRPC::Lite
/usr/bin/perl install-module.pl JSON::RPC
/usr/bin/perl install-module.pl HTML::FormatText::WithLinks
/usr/bin/perl install-module.pl TheSchwartz
/usr/bin/perl install-module.pl Daemon::Generic
/usr/bin/perl install-module.pl File::MimeInfo::Magic
/usr/bin/perl install-module.pl Daemon::Generic

Finishing up

You would still have to create the database and configure some parameters, but hopefully there is documentation for that already.

$ ./checksetup.pl