Setting up a Bugzilla server inside a Win10 Linux Subsystem went far smoother than I expected

Setting up a Bugzilla server inside a Win10 Linux Subsystem went far smoother than I expected

I recently hit a bit of a slump as far as my personal programming projects go so I decided to shame myself into keeping busy by setting up a Bugzilla server on my home machine.

Since if something's worth doing then it's worth overdoing I also decided to take the opportunity to refresh my at best tentative relation with linux and take advantage of the linux subsystem that's been available in Win10 for a while now.

Plus, the Bugzilla people all but recommend a linux installation as better supported, and you also reap the benefits of indulging in an isolated environment, for instance if you've currently no use for Perl and don't want to have to switch around your mysql version.


1. Getting the Windows Linux Subsystem (WLS)

is now as simple as running a command in powershell and getting your distro of choice from the Microsoft Store:

# Enable bash as a windows feature using powershell
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Next, head to the app store and get the latest version of Ubuntu, Bionic Beaver 18.04 as of this writing.

Ubuntu Bionic Beaver in Windows App Store

Different Linux subsystem distributions have different kinks, but let's stick to Ubuntu for now. It's a meager 215MB download, which is of course nowhere near the size of an actual ubuntu installation disk.

Installing WLS (the Windows Linux Subsystem) when it was first introduced used to be a slightly more involving process that included fidgeting with windows beta features and switching windows to developer mode.




2. Setting up the WLS

Click on the bash icon in the start menu, wait a bit, then set a root password when asked to and you are basically done. All that's left is to make sure that apt's repository information is up to date and we'll leave the operating system alone for a while. Just run:

sudo su
apt-get update

After sudo su you'll be asked to entered the root password you just created.

sudo su logs you in as a [s]uper [u]ser. Which is nice, since now you won't have to use sudo and reenter the root password before almost every command, which is a lot like not having to see Windows' Do you want to allow this app to make changes to your device? popup every two seconds during long installs.

Another tell that you are logged in with elevated priviledges is that the prompt ends with an # instead of $.



3. Bugzilla: Gathering the ingredients

The good people of Bugzilla helpfully list all the packages that will have to be present in order to get things working. However a few of the packages either don't yet have a version available for Bionic, others have been merged into new packages and yet others can even be omitted altogether. This is the final list that I went with (I'm including git, which although present in WLS, at the time of writing a newer version was available):

apt-get install git apache2 mysql-server libappconfig-perl libdate-calc-perl libtemplate-perl build-essential libdatetime-timezone-perl libdatetime-perl libemail-sender-perl libemail-mime-perl libdbi-perl libdbd-mysql-perl libcgi-pm-perl libmath-random-isaac-perl libmath-random-isaac-xs-perl libapache2-mod-perl2 libapache2-mod-perl2-dev libchart-perl libxml-perl libxml-twig-perl perlmagick libgd-graph-perl libtemplate-plugin-gd-perl libsoap-lite-perl libhtml-scrubber-perl libjson-rpc-perl libdaemon-generic-perl libtheschwartz-perl libtest-taint-perl libauthen-radius-perl libfile-slurp-perl libencode-detect-perl libmodule-build-perl libnet-ldap-perl libfile-which-perl libauthen-sasl-perl libfile-mimeinfo-perl libhtml-formattext-withlinks-perl libgd-dev libmysqlclient-dev graphviz python-sphinx rst2pdf


This should set you back a good .5GB or so. That done, it's finally time to get the Bugzilla files themselves, using git. You can check out bugzilla to any arbitrary location you want, but eventually you'll have to configure apache around it, so you might as well place it at /var/www/html/bugzilla from the start.

As usual, this command will get you the latest available version at the time of writing.

git clone --branch release-5.0-stable /var/www/html/bugzilla
You can save some time by separately apt-getting git and mysql, thus freeing you up to open a couple more bash windows to simultaneously download the Bugzilla files and configure mysql (see next step) while the rest of the packages are downloading.



4. Configuring MySQL

Since WLS is using the same port space as windows, if you already have a mysqlserver windows service running there will be conflicts, especially if you've used the default settings. For now I'd recommend stopping the windows service. 

First you need to start the service within WLS:

service mysql start

That done, run the mysql installation helper which will let you set a root password and set some security options:


Then create the bugs user:

mysql -u root -p -e "GRANT ALL PRIVILEGES ON bugs.* TO bugs@localhost IDENTIFIED BY 'some strong password'"

Running this command will prompt you to enter the password you registered in the previous step before making any changes to the database. 

It goes without saying that you'll have to keep track good of this password, since bugzilla's communication with the database depends on it.

Then we make some changes to the mysql configuration file, normally found at /etc/mysql/my.cnf. Your fresh WLS installation comes with the nano editor, so let's use that:

nano /etc/mysql/my.cnf

Now add the following at the end, or under any existing [mysqld] section:


You save and exit in nano by pressing ctrl+X and enter.

Finally, restart the service for the changes to take effect:

service mysql restart


max_allowed_paket basically defines the maximum space that a bugzilla issue with all it's attachments and comments is allowed to take, and some mysql installations default this to as low as 1MB. You can be flexible as to what upper limit you use, but you will have to keep track of it if in the future you need to migrate your database to a different bugzilla installation, in case it has been configured at a lower limit. 

More info on further configuring mysql for bugzilla here.



5. And then slightly tweaking Apache

Since windows and WLS are using the same ports, keeping the default setting of apache listening on port 80 is not going to end well. We can fix this thus:

nano /etc/apache2/ports.conf

And then change Listen 80 to something like 8080.

Now all that's left is to tell apache how to handle what we put at /var/www/html/bugzilla:

nano /etc/apache2/apache2.conf

Add (preferably near the other <directory> definitions) :

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

Finally make sure the Apache CGI module is enabled:

a2enmod cgi

And we are just about good to go.

For more information about setting up apache for bugzilla go here.

To make sure nothing has gone horribly wrong yet, you can enter apachectl start in bash to start apache, and then enter localhost:8080 on the address bar of any browser window. If you see the Apache2 Ubuntu Default Page, then we're doing just about ok.




6. Bugzilla!

First make sure that apache and myslqserver are running:

# Don't worry about sudo su if you're already logged as root
sudo su
service apache2 status
service mysql status
# If they aren't running start them like this:
apachectl start
service mysql start

With that out of the way, go to our bugzilla directory (/var/www/html/bugzilla) and dot slash run the installation script:


If all goes well at the end you'll get a notice asking you to enter the value for a couple of variables in a file called localconfig. So let's do that:

nano localconfig

Change $webservergroup to www-data and $db_pass to the password you created for user bugs when configuring mysql.

Following that, run again.

If you find you've made a mistake such as missing a couple of characters from your password it's ok to go back to localconfig and run again. 

If all went well, it's time to enter you administrator credentials for bugzilla!

Be sure to make the real name of the administrator at least three characters, or you'll have trouble using it at the website.

If all goes well then congratulations, go to http://localhost:8080/bugzilla and login as the administrator!


7. Starting Bugzilla from outside the WLS (optional)

Firing up Bugzilla without needing to manually open bash and start apache & mysql would be pretty handy, not to mention being able to turn it off at short notice if you decide you need the port space.

Turns out sending commands to bash from a win10 console is pretty simple: just run bash with the -c option followed by your commands.

For example:

# start everything
bash -c "sudo service mysql start; sudo apachectl start"
# stop everything
bash -c "sudo service mysql stop; sudo apachectl stop"
# create a file to point a shortcut to
'bash -c "sudo service mysql start; sudo apachectl start"' > bugzilla-start.cmd
# if you run into any codepage difficulties
'bash -c "sudo service mysql start; sudo apachectl start"' | Set-Content bugzilla-start.cmd -Encoding Default

The only downside is you'll have to manually enter your root password every time, but hey.


8. Fixing the timezone error

Software error: Cannot determine local timezone


Just one last thing to do, otherwise every time we try to log a bug the process will fail with a Cannot determine local time zone error. This is a WLS bug that has been around a while. I suppose MS will eventually get to fixing it, but in the meantime here is a simple workaround:

First find your timezone in /usr/share/zoneinfo

 ls /usr/share/zoneinfo -l

I used /usr/share/zoneinfo/Europe/Athens which corresponds to the timezone for Greece.

Simply replace /etc/localtime with a symbolic link to your own timezone (or any timezone for that matter).

rm /etc/localtime
ln -s /usr/share/zoneinfo/Europe/Athens /etc/localtime

And we are done! Hope you've had an interesting time poking around in the WLS, now go log some bugs, or maybe open a ticket to track your grocery list. Cheers!


Bugzilla launch page