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.
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.
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.
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 https://github.com/bugzilla/bugzilla /var/www/html/bugzilla
4. Configuring MySQL
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:
Now add the following at the end, or under any existing [mysqld] section:
[mysqld] max_allowed_packet=16M ft_min_word_len=2
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
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:
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:
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 </Directory>
Finally make sure the Apache CGI module is enabled:
And we are just about good to go.
For more information about setting up apache for bugzilla go here.
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:
Change $webservergroup to www-data and $db_pass to the password you created for user bugs when configuring mysql.
Following that, run checksetup.pl again.
If all went well, it's time to enter you administrator credentials for bugzilla!
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.
# 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
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!