2.2. Configuration

[Warning]

Poorly-configured MySQL and Bugzilla installations have given attackers full access to systems in the past. Please take the security parts of these guidelines seriously, even for Bugzilla machines hidden away behind your firewall. Be certain to read Chapter 4, Bugzilla Security for some important security tips.

2.2.1. localconfig

You should now run checksetup.pl again, this time without the --check-modules switch.

bash# ./checksetup.pl

This time, checksetup.pl should tell you that all the correct modules are installed and will display a message about, and write out a file called, localconfig. This file contains the default settings for a number of Bugzilla parameters.

Load this file in your editor. The only two values you need to change are $db_driver and $db_pass, respectively the type of the database and the password for the user you will create for your database. Pick a strong password (for simplicity, it should not contain single quote characters) and put it here. $db_driver can be either 'mysql', 'Pg', 'Oracle' or 'Sqlite'.

[Note]

In Oracle, $db_name should actually be the SID name of your database (e.g. "XE" if you are using Oracle XE).

You may need to change the value of webservergroup if your web server does not run in the "apache" group. On Debian, for example, Apache runs in the "www-data" group. If you are going to run Bugzilla on a machine where you do not have root access (such as on a shared web hosting account), you will need to leave webservergroup empty, ignoring the warnings that checksetup.pl will subsequently display every time it is run.

[Caution]

If you are using suexec, you should use your own primary group for webservergroup rather than leaving it empty, and see the additional directions in the suexec section Section 2.6.6.1, “suexec or shared hosting”.

The other options in the localconfig file are documented by their accompanying comments. If you have a slightly non-standard database setup, you may wish to change one or more of the other "$db_*" parameters.

2.2.2. Database Server

This section deals with configuring your database server for use with Bugzilla. Currently, MySQL (Section 2.2.2.2, “MySQL”), PostgreSQL (Section 2.2.2.3, “PostgreSQL”), Oracle (Section 2.2.2.4, “Oracle”) and SQLite (Section 2.2.2.5, “SQLite”) are available.

2.2.2.1. Bugzilla Database Schema

The Bugzilla database schema is available at Ravenbrook. This very valuable tool can generate a written description of the Bugzilla database schema for any version of Bugzilla. It can also generate a diff between two versions to help someone see what has changed.

2.2.2.2. MySQL

[Caution]

MySQL's default configuration is insecure. We highly recommend to run mysql_secure_installation on Linux or the MySQL installer on Windows, and follow the instructions. Important points to note are:

  1. Be sure that the root account has a secure password set.

  2. Do not create an anonymous account, and if it exists, say "yes" to remove it.

  3. If your web server and MySQL server are on the same machine, you should disable the network access.

2.2.2.2.1. Allow large attachments and many comments

By default, MySQL will only allow you to insert things into the database that are smaller than 1MB. Attachments may be larger than this. Also, Bugzilla combines all comments on a single bug into one field for full-text searching, and the combination of all comments on a single bug could in some cases be larger than 1MB.

To change MySQL's default, you need to edit your MySQL configuration file, which is usually /etc/my.cnf on Linux. We recommend that you allow at least 4MB packets by adding the "max_allowed_packet" parameter to your MySQL configuration in the "[mysqld]" section, like this:

[mysqld]
# Allow packets up to 4MB
max_allowed_packet=4M
          
2.2.2.2.2. Allow small words in full-text indexes

By default, words must be at least four characters in length in order to be indexed by MySQL's full-text indexes. This causes a lot of Bugzilla specific words to be missed, including "cc", "ftp" and "uri".

MySQL can be configured to index those words by setting the ft_min_word_len param to the minimum size of the words to index. This can be done by modifying the /etc/my.cnf according to the example below:

[mysqld]
# Allow small words in full-text indexes
ft_min_word_len=2

Rebuilding the indexes can be done based on documentation found at http://www.mysql.com/doc/en/Fulltext_Fine-tuning.html.

2.2.2.2.3. Add a user to MySQL

You need to add a new MySQL user for Bugzilla to use. (It's not safe to have Bugzilla use the MySQL root account.) The following instructions assume the defaults in localconfig; if you changed those, you need to modify the SQL command appropriately. You will need the $db_pass password you set in localconfig in Section 2.2.1, “localconfig”.

We use an SQL GRANT command to create a bugs user. This also restricts the bugsuser to operations within a database called bugs, and only allows the account to connect from localhost. Modify it to reflect your setup if you will be connecting from another machine or as a different user.

Run the mysql command-line client and enter:

mysql> GRANT SELECT, INSERT,
       UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES,
       CREATE TEMPORARY TABLES, DROP, REFERENCES ON bugs.*
       TO bugs@localhost IDENTIFIED BY '$db_pass';
mysql> FLUSH PRIVILEGES;
          
2.2.2.2.4. Permit attachments table to grow beyond 4GB

By default, MySQL will limit the size of a table to 4GB. This limit is present even if the underlying filesystem has no such limit. To set a higher limit, follow these instructions.

After you have completed the rest of the installation (or at least the database setup parts), you should run the MySQL command-line client and enter the following, replacing $bugs_db with your Bugzilla database name (bugs by default):

mysql> use $bugs_db
mysql> ALTER TABLE attachments
           AVG_ROW_LENGTH=1000000, MAX_ROWS=20000;
          

The above command will change the limit to 20GB. Mysql will have to make a temporary copy of your entire table to do this. Ideally, you should do this when your attachments table is still small.

[Note]

This does not affect Big Files, attachments that are stored directly on disk instead of in the database.

2.2.2.3. PostgreSQL

2.2.2.3.1. Add a User to PostgreSQL

You need to add a new user to PostgreSQL for the Bugzilla application to use when accessing the database. The following instructions assume the defaults in localconfig; if you changed those, you need to modify the commands appropriately. You will need the $db_pass password you set in localconfig in Section 2.2.1, “localconfig”.

On most systems, to create the user in PostgreSQL, you will need to login as the root user, and then

bash# su - postgres

As the postgres user, you then need to create a new user:

bash$ createuser -U postgres -dRSP bugs

When asked for a password, provide the password which will be set as $db_pass in localconfig. The created user will not be a superuser (-S) and will not be able to create new users (-R). He will only have the ability to create databases (-d).

2.2.2.3.2. Configure PostgreSQL

Now, you will need to edit pg_hba.conf which is usually located in /var/lib/pgsql/data/. In this file, you will need to add a new line to it as follows:

host all bugs 127.0.0.1 255.255.255.255 md5

This means that for TCP/IP (host) connections, allow connections from '127.0.0.1' to 'all' databases on this server from the 'bugs' user, and use password authentication (md5) for that user.

Now, you will need to restart PostgreSQL, but you will need to fully stop and start the server rather than just restarting due to the possibility of a change to postgresql.conf. After the server has restarted, you will need to edit localconfig, finding the $db_driver variable and setting it to Pg and changing the password in $db_pass to the one you picked previously, while setting up the account.

2.2.2.4. Oracle

2.2.2.4.1. Create a New Tablespace

You can use the existing tablespace or create a new one for Bugzilla. To create a new tablespace, run the following command:

CREATE TABLESPACE bugs
DATAFILE '$path_to_datafile' SIZE 500M
AUTOEXTEND ON NEXT 30M MAXSIZE UNLIMITED
          

Here, the name of the tablespace is 'bugs', but you can choose another name. $path_to_datafile is the path to the file containing your database, for instance /u01/oradata/bugzilla.dbf. The initial size of the database file is set in this example to 500 Mb, with an increment of 30 Mb everytime we reach the size limit of the file.

2.2.2.4.2. Add a User to Oracle

The user name and password must match what you set in localconfig ($db_user and $db_pass, respectively). Here, we assume that the user name is 'bugs' and the tablespace name is the same as above.

CREATE USER bugs
IDENTIFIED BY "$db_pass"
DEFAULT TABLESPACE bugs
TEMPORARY TABLESPACE TEMP
PROFILE DEFAULT;
-- GRANT/REVOKE ROLE PRIVILEGES
GRANT CONNECT TO bugs;
GRANT RESOURCE TO bugs;
-- GRANT/REVOKE SYSTEM PRIVILEGES
GRANT UNLIMITED TABLESPACE TO bugs;
GRANT EXECUTE ON CTXSYS.CTX_DDL TO bugs;
          
2.2.2.4.3. Configure the Web Server

If you use Apache, append these lines to httpd.conf to set ORACLE_HOME and LD_LIBRARY_PATH. For instance:

SetEnv ORACLE_HOME /u01/app/oracle/product/10.2.0/
SetEnv LD_LIBRARY_PATH /u01/app/oracle/product/10.2.0/lib/
          

When this is done, restart your web server.

2.2.2.5. SQLite

[Caution]

Due to SQLite's concurrency limitations we recommend SQLite only for small and development Bugzilla installations.

No special configuration is required to run Bugzilla on SQLite. The database will be stored in data/db/$db_name, where $db_name is the database name defined in localconfig.

2.2.3. checksetup.pl

Next, rerun checksetup.pl. It reconfirms that all the modules are present, and notices the altered localconfig file, which it assumes you have edited to your satisfaction. It compiles the UI templates, connects to the database using the 'bugs' user you created and the password you defined, and creates the 'bugs' database and the tables therein.

After that, it asks for details of an administrator account. Bugzilla can have multiple administrators - you can create more later - but it needs one to start off with. Enter the email address of an administrator, his or her full name, and a suitable Bugzilla password.

checksetup.pl will then finish. You may rerun checksetup.pl at any time if you wish.

2.2.4. Web server

Configure your web server according to the instructions in the appropriate section. (If it makes a difference in your choice, the Bugzilla Team recommends Apache.) To check whether your web server is correctly configured, try to access testagent.cgi from your web server. If "OK" is displayed, then your configuration is successful. Regardless of which web server you are using, however, ensure that sensitive information is not remotely available by properly applying the access controls in Section 4.2.1, “Disabling Remote Access to Bugzilla Configuration Files”. You can run testserver.pl to check if your web server serves Bugzilla files as expected.

2.2.4.1. Bugzilla using Apache

You have two options for running Bugzilla under Apache - mod_cgi (the default) and mod_perl (new in Bugzilla 2.23)

2.2.4.1.1. Apache httpd™ with mod_cgi

To configure your Apache web server to work with Bugzilla while using mod_cgi, do the following:

  1. Load httpd.conf in your editor. In Fedora and Red Hat Linux, this file is found in /etc/httpd/conf.

  2. Apache uses <Directory> directives to permit fine-grained permission setting. Add the following lines to a directive that applies to the location of your Bugzilla installation. (If such a section does not exist, you'll want to add one.) In this example, Bugzilla has been installed at /var/www/html/bugzilla.

    <Directory /var/www/html/bugzilla>
    AddHandler cgi-script .cgi
    Options +ExecCGI
    DirectoryIndex index.cgi index.html
    AllowOverride All
    </Directory>
                    

    These instructions: allow apache to run .cgi files found within the bugzilla directory; instructs the server to look for a file called index.cgi or, if not found, index.html if someone only types the directory name into the browser; and allows Bugzilla's .htaccess files to override some global permissions.

    [Note]

    It is possible to make these changes globally, or to the directive controlling Bugzilla's parent directory (e.g. <Directory /var/www/html/>). Such changes would also apply to the Bugzilla directory... but they would also apply to many other places where they may or may not be appropriate. In most cases, including this one, it is better to be as restrictive as possible when granting extra access.

    [Note]

    On Windows, you may have to also add the ScriptInterpreterSource Registry-Strict line, see Windows specific notes.

  3. checksetup.pl can set tighter permissions on Bugzilla's files and directories if it knows what group the web server runs as. Find the Group line in httpd.conf, place the value found there in the $webservergroup variable in localconfig, then rerun checksetup.pl.

  4. Optional: If Bugzilla does not actually reside in the webspace directory, but instead has been symbolically linked there, you will need to add the following to the Options line of the Bugzilla <Directory> directive (the same one as in the step above):

    +FollowSymLinks

    Without this directive, Apache will not follow symbolic links to places outside its own directory structure, and you will be unable to run Bugzilla.

2.2.4.1.2. Apache httpd™ with mod_perl

Some configuration is required to make Bugzilla work with Apache and mod_perl

  1. Load httpd.conf in your editor. In Fedora and Red Hat Linux, this file is found in /etc/httpd/conf.

  2. Add the following information to your httpd.conf file, substituting where appropriate with your own local paths.

    [Note]

    This should be used instead of the <Directory> block shown above. This should also be above any other mod_perl directives within the httpd.conf and must be specified in the order as below.

    [Warning]

    You should also ensure that you have disabled KeepAlive support in your Apache install when utilizing Bugzilla under mod_perl

    PerlSwitches -w -T
    PerlConfigRequire /var/www/html/bugzilla/mod_perl.pl
                    
  3. checksetup.pl can set tighter permissions on Bugzilla's files and directories if it knows what group the web server runs as. Find the Group line in httpd.conf, place the value found there in the $webservergroup variable in localconfig, then rerun checksetup.pl.

On restarting Apache, Bugzilla should now be running within the mod_perl environment. Please ensure you have run checksetup.pl to set permissions before you restart Apache.

[Note]

Please bear the following points in mind when looking at using Bugzilla under mod_perl:

  • mod_perl support in Bugzilla can take up a HUGE amount of RAM. You could be looking at 30MB per httpd child, easily. Basically, you just need a lot of RAM. The more RAM you can get, the better. mod_perl is basically trading RAM for speed. At least 2GB total system RAM is recommended for running Bugzilla under mod_perl.

  • Under mod_perl, you have to restart Apache if you make any manual change to any Bugzilla file. You can't just reload--you have to actually restart the server (as in make sure it stops and starts again). You can change localconfig and the params file manually, if you want, because those are re-read every time you load a page.

  • You must run in Apache's Prefork MPM (this is the default). The Worker MPM may not work--we haven't tested Bugzilla's mod_perl support under threads. (And, in fact, we're fairly sure it won't work.)

  • Bugzilla generally expects to be the only mod_perl application running on your entire server. It may or may not work if there are other applications also running under mod_perl. It does try its best to play nice with other mod_perl applications, but it still may have conflicts.

  • It is recommended that you have one Bugzilla instance running under mod_perl on your server. Bugzilla has not been tested with more than one instance running.

2.2.4.2. Microsoft Internet Information Services

If you are running Bugzilla on Windows and choose to use Microsoft's Internet Information Services™ or Personal Web Server™ you will need to perform a number of other configuration steps as explained below. You may also want to refer to the following Microsoft Knowledge Base articles: 245225 HOW TO: Configure and Test a PERL Script with IIS 4.0, 5.0, and 5.1 (for Internet Information Services™) and 231998 HOW TO: FP2000: How to Use Perl with Microsoft Personal Web Server on Windows 95/98 (for Personal Web Server™).

You will need to create a virtual directory for the Bugzilla install. Put the Bugzilla files in a directory that is named something other than what you want your end-users accessing. That is, if you want your users to access your Bugzilla installation through http://<yourdomainname>/Bugzilla, then do not put your Bugzilla files in a directory named Bugzilla. Instead, place them in a different location, and then use the IIS Administration tool to create a Virtual Directory named "Bugzilla" that acts as an alias for the actual location of the files. When creating that virtual directory, make sure you add the Execute (such as ISAPI applications or CGI) access permission.

You will also need to tell IIS how to handle Bugzilla's .cgi files. Using the IIS Administration tool again, open up the properties for the new virtual directory and select the Configuration option to access the Script Mappings. Create an entry mapping .cgi to:

<full path to perl.exe >\perl.exe -x<full path to Bugzilla> -wT "%s" %s
        

For example:

c:\perl\bin\perl.exe -xc:\bugzilla -wT "%s" %s
        
[Note]

The ActiveState install may have already created an entry for .pl files that is limited to GET,HEAD,POST. If so, this mapping should be removed as Bugzilla's .pl files are not designed to be run via a web server.

IIS will also need to know that the index.cgi should be treated as a default document. On the Documents tab page of the virtual directory properties, you need to add index.cgi as a default document type. If you wish, you may remove the other default document types for this particular virtual directory, since Bugzilla doesn't use any of them.

Also, and this can't be stressed enough, make sure that files such as localconfig and your data directory are secured as described in Section 4.2.1, “Disabling Remote Access to Bugzilla Configuration Files”.

2.2.5. Bugzilla

Your Bugzilla should now be working. Access http://<your-bugzilla-server>/ - you should see the Bugzilla front page. If not, consult the Troubleshooting section, Appendix A, Troubleshooting.

[Note]

The URL above may be incorrect if you installed Bugzilla into a subdirectory or used a symbolic link from your web site root to the Bugzilla directory.

Log in with the administrator account you defined in the last checksetup.pl run. You should go through the Parameters page and see if there are any you wish to change. They key parameters are documented in Section 3.1, “Bugzilla Configuration”; you should certainly alter maintainer and urlbase; you may also want to alter cookiepath or requirelogin.

Bugzilla has several optional features which require extra configuration. You can read about those in Section 2.3, “Optional Additional Configuration”.