Joyent

Installing FogBugz 6.0 on a Joyent Accelerator

This was tested on a pristine 1/4GB accelerator.

I assume you’re running everything with an admin user, meaning you can sudo anytime.

Getting your environment ready

1. Put stuff in your PATH

Edit your .bashrc1) have php readily available in your PATH environment variable. We’ll also need to have /usr/local/bin in it, I’ll explain why later. Add this to the end of the file:

export PATH=$PATH:/usr/local/bin:/opt/csw/php5/bin
  

Because editing files is boring, you might just wanna type this:

$ echo "export PATH=$PATH:/usr/local/bin:/opt/csw/php5/bin" | cat >> ~/.bashrc

Run that export line in your shell too, or login again, to make sure it’s in effect. By now you should be able to call php and pear:

$ which php
php is /opt/csw/php5/bin/php
$ which pear
pear is /opt/csw/php5/bin/pear

2. FogBugz is hungry

You’ll need to up some limits in your php.ini and my.cnf.

Edit /opt/csw/php5/lib/php.ini, change the value for memory_limit to 128MB.2)

Also, edit /opt/csw/mysql5/my.cnf and change max_allowed_packet to 50M.

Or, have perl do it for you:

$ sudo -s
# sudo perl -i -pe 's/(max_allowed_packet = )\w+/$150MB/' /opt/csw/mysql5/my.cnf
# sudo perl -i -pe 's/(memory_limit = )\w+/$1128MB/' /opt/csw/mysql5/my.cnf

Then restart apache and mysql

# svcadm restart cswmysql5
# svcadm restart cswapache2

3. Fix PEAR

The pear that comes with your accelerator has a weird proxy setting that will keep it from working. It also doesn’t know where your php.ini is. You’ll need to fix these settings then upgrade pear to a more recent version to use it with FogBugz:

$ sudo -s
# pear config-set http_proxy ''
# pear config-set php_ini /opt/csw/php5/lib/php.ini
# pear upgrade PEAR

4. Let Apache find mono

We haven’t installed mono yet, but we’ll later need Apache to be able to find it, so we’ll change its PATH.

I’m probably adding more than necessary here, but it can’t hurt.

$ sudo -s
# svccfg -s network/http:cswapache2 setenv -m start PATH \
"/usr/sbin:/usr/bin:/usr/sfw/bin:/opt/csw/bin:/opt/csw/sbin:/opt/csw/gnu:\
/opt/csw/gcc3/bin:/opt/csw/mysql5/bin:/opt/csw/postgresql/bin:\
/opt/csw/apache2/bin:/opt/csw/apache2/sbin:/usr/local/bin:/opt/csw/php5/bin"
# svcadm refresh cswapache2
# svcadm restart cswapache2

Checking requirements

Check the requirements mentioned in the FogBugz docs. Here’s the output for my accelerator.

Things you should have:

$ php --version | head -n1
PHP 5.2.1 (cli) (built: Mar 15 2007 12:08:55) 
 
$ php -m | egrep '^(xml|iconv|imap|mysql)$' | xargs echo
iconv imap mysql xml
 
$ pear version 2>&1 | head -n1
PEAR Version: 1.7.1
 
$ mysqladmin version | grep Server
Server version          5.0.37-log
 
$ curl --version | head -n1
curl 7.16.1 (i386-pc-solaris2.8) libcurl/7.16.1 OpenSSL/0.9.8d zlib/1.2.3 libidn/0.5.19

Things you probably don't have:

$ which mono
-bash: type: mono: not found
 
$ php -m | grep eAccelerator

Meeting requirements

So we’ll start by the hard part which is properly installing mono, then we’ll go on to installing eAccelerator. Before we can have fun compiling things, we’ll need bison and pkgconfig. 3) It’s a couple if one-liners with Blastwave:

$ sudo pkg-get install bison
$ sudo pkg-get install pkgconfig

Next, we’ll need a directory to put the sources we’re going to compile:

$ mkdir ~/src

Installing mono

Installing mono is a piece of cake as long as you know the magic words. Here they are, don’t ask. I don’t remember why all of that, some may be even be useless, but that gets it compiled right, so enjoy.

$ cd ~/src
$ curl -s http://ftp.novell.com/pub/mono/sources/mono/mono-1.9.tar.bz2 | tar jx
$ cd mono-1.9
$ LD_LIBRARY_PATH=/opt/csw/lib MAKE=gmake RANLIB=granlib AR=gar STRIP=gstrip ./configure
$ for a in `find ./ -name Makefile`; do \
  cp $a $a.1; cat $a.1 | sed -e 's/-mt/-D_REENTRANT/' > $a; rm $a.1; done
$ LD_LIBRARY_PATH=/opt/csw/lib gmake
$ sudo gmake install

This should take a while. Go make yourself a nice cup of tea.

When you’re back, configure the linker to look in /usr/local/lib

  
$ sudo crle -c /var/ld/ld.config -l /lib:/usr/lib:/usr/local/lib

Mono will install to /usr/local, which is actually a symlink to /opt/local. Anyway, that’s why you added it to your PATH before.

Now you should be able to call mono:

$ mono --version | head -n1
Mono JIT compiler version 1.9 (tarball)

Installing eAccelerator

You can follow the instructions here, or you can take my copy and paste shell commands for granted.

First, compile and install.

$ cd ~/src
$ curl -s http://bart.eaccelerator.net/source/0.9.5.2/eaccelerator-0.9.5.2.tar.bz2 | tar jx
$ cd eaccelerator-0.9.5.2/
$ phpize
$ ./configure 
$ make
$ sudo make install

Then configure your php.ini. Again, I think editors are overrated. Just use cat.

$ sudo -s
# echo '
 
; install eaccelerator as a zend_extension
zend_extension="/opt/csw/php5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
' | cat >> /opt/csw/php5/lib/php.ini
# exit

After that, you should be able to check for eAccelerator:

$ php -m | grep eAccelerator
eAccelerator
eAccelerator

Installing FogBugz, at last

Download FogBugz from FogCreek and upload it to your server. You could use scp for that. On your local machine run:

$ scp fogbugz-setup-php-6.1.19.tar.gz your-accelerator-host:src/
  

Then in your accelerator:4)

$ cd ~/src
$ tar zxf fogbugz-setup-php-6.1.19.tar.gz 
$ cd fogbugz/
  

Now, before we can run FogBugz’s install.sh, we need to customize it. First off, there’s something weird with the sh in my accelerator that it will not recognize some things. So we’ll just use bash. Edit the shebang line to be:

#!/usr/bin/bash

Then we’ll need to change some variables. Right at the beginning of the script you’ll see INSTALL_DIR. I suggest you just leave it as is. Then there is USE_APACHE2. You need to change that to 1:

USE_APACHE2=1

Further, you may want to customize the HOSTNAME variable to be the domain you’ll use to access FogBugz, which might differ from the machine’s hostname if you’re using virtual hosts.

Then there are a handful of findFile calls. You’ll need to add your paths to these lists, because they won’t know where stuff is in your accelerator. So, look for

findFile "/opt/local/apache2/conf/httpd.conf ..."
  

And prepend the list with your apache conf path:

findFile "/opt/csw/apache2/etc/httpd.conf ..."

You’ll also need to do that for php.ini and apachectl:

findFile "/opt/local/etc/php.ini ..."
findFile "/opt/csw/php5/lib/php.ini ..."
 
findFile "/opt/local/apache2/bin/apachectl ..."
findFile "/opt/csw/apache2/sbin/apachectl ..."

And lastly, you need to add your apache user to the list of apache users the script will look for:

for f in www-data ...
for f in webservd ...

Here’s a bit of perl magic that’ll do it all for you:

$ perl -i -pe 's|#!/bin/sh|#!/usr/bin/bash|' install.sh
$ perl -i -pe 's|USE_APACHE2=0|USE_APACHE2=1|' install.sh
$ perl -i -pe 's|(findFile ")(.*?httpd\.conf)|$1/opt/csw/apache2/etc/httpd.conf $2|' install.sh
$ perl -i -pe 's|(findFile ")(.*?php\.ini)|$1/opt/csw/php5/lib/php.ini $2|' install.sh
$ perl -i -pe 's|(findFile ")(.*?apachectl)|$1/opt/csw/apache2/sbin/apachectl $2|' install.sh
$ perl -i -pe 's|(for f in )(.*?apache)|$1webservd $2|' install.sh

Now you can run install.sh.

$ sudo ./install.sh

It’ll ask to install a handful of PEAR modules. Just say yes every time.

The installer will also ask to update your php.ini and httpd.conf. You can let it do it. Here’s what it’ll append to the files:

httpd.conf:

# Automatically added by FogBugz
Include "/opt/fogbugz/Accessories/fogbugz.conf"

php.ini:

; Automatically added by FogBugz
extension=fogutil.so
error_reporting = E_ALL & ~E_NOTICE
display_errors = Off
memory_limit = 256M

The installer will fail to copy the FogBugz shared object. Do that manually:

$ sudo cp ~/src/fogbugz/Accessories/fogutil.php5.2-solaris-i686-dynamic.so \
  /opt/csw/php5/lib/php/extensions/no-debug-non-zts-20060613/fogutil.so

It’ll also fail to restart apache. Again, you can do it:

$ sudo svcadm restart cswapache2
  

Once you’re done, you can visit:

http://ACCELERATOR_IP_ADDRESS/fogbugz/install1.php

Follow the steps on the screen. It’ll ask for credentials to and create a MySQL database, then it’ll ask for your licenses. Finally, it’ll have you configure SMTP. That should get you running, except for a couple of things:

Being reboot-safe and avoiding funny errors

FogBugz keeps two programs running on the server, the search and the maintenance daemons.

The installer put scripts in your rc directories to have them started at the appropriate times and all that. But... they won’t work. So the cool Solaris thing to do is to remove them, and have the SMF handle it all for you instead. Let’s start by removing them:

$ sudo -s
# rm /etc/init.d/fogbugzmaintd
# rm /etc/rc0.d/K99fogbugz-search
# rm /etc/rc0.d/K99fogbugzmaintd
# rm /etc/rc1.d/K99fogbugz-search
# rm /etc/rc1.d/K99fogbugzmaintd
# rm /etc/rc2.d/S99fogbugz-search
# rm /etc/rc2.d/S99fogbugzmaintd
# rm /etc/rc3.d/S99fogbugz-search
# rm /etc/rc3.d/S99fogbugzmaintd

We’ll keep /etc/init.d/fogbugz-search around because we’ll use it in the search manifest.

Again, we’ll need to change its shebang:

$ sudo perl -i -pe 's|#!/bin/sh|#!/usr/bin/bash|' /etc/init.d/fogbugz-search

Then we’ll create and import the manifests. Copy and paste the XML code that follows into files called maintenance.xml and search.xml. You could do that with cat. After you’re done pasting, press ctrl+D.

$ cd ~/src
$ cat > maintenance.xml
... paste stuff
^D
$ cat > search.xml
... paste stuff
^D

maintenance.xml

<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
  <service name='application/fogbugz/maintenance' type='service' version='0'>
    <create_default_instance enabled='true'/>
    <single_instance/>
    <dependency name='fs' grouping='require_all' restart_on='none' type='service'>
      <service_fmri value='svc:/system/filesystem/local'/>
    </dependency>
    <dependency name='net' grouping='require_all' restart_on='none' type='service'>
      <service_fmri value='svc:/network/loopback'/>
    </dependency>
    <dependent name='fogbugzmaintd_multi-user' restart_on='none' grouping='optional_all'>
      <service_fmri value='svc:/milestone/multi-user'/>
    </dependent>
    <exec_method name='start' type='method' exec='nohup php -d max_execution_time=0 -d allow_call_time_pass_reference=Yes ./fogbugzmaintd.php &gt;/dev/null &amp;' timeout_seconds='60'>
      <method_context working_directory='/opt/fogbugz/Accessories'>
        <method_credential user='root' group='root'/>
        <method_environment>
          <envvar name='PATH' value='/usr/local/bin:/usr/sbin:/usr/bin:/usr/sfw/bin:/opt/csw/bin:/opt/csw/sbin:/opt/csw/gnu:/opt/csw/mysql5/bin:/opt/csw/php5/bin'/>
        </method_environment>
      </method_context>
    </exec_method>
    <exec_method name='stop' type='method' exec=':kill' timeout_seconds='60'>
      <method_context/>
    </exec_method>
    <template>
      <common_name>
        <loctext xml:lang='C'>FogBugz maintenance daemon</loctext>
      </common_name>
    </template>
  </service>
</service_bundle>
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
  <service name='application/fogbugz/search' type='service' version='0'>
    <create_default_instance enabled='true'/>
    <single_instance/>
    <dependency name='fs' grouping='require_all' restart_on='none' type='service'>
      <service_fmri value='svc:/system/filesystem/local'/>
    </dependency>
    <dependency name='net' grouping='require_all' restart_on='none' type='service'>
      <service_fmri value='svc:/network/loopback'/>
    </dependency>
    <dependent name='fogbugzsearch_multi-user' restart_on='none' grouping='optional_all'>
      <service_fmri value='svc:/milestone/multi-user'/>
    </dependent>
    <exec_method name='start' type='method' exec='/etc/init.d/fogbugz-search start' timeout_seconds='60'>
      <method_context working_directory='/opt/fogbugz/Accessories'>
        <method_credential user='root' group='root'/>
        <method_environment>
          <envvar name='PATH' value='/usr/local/bin:/usr/sbin:/usr/bin:/usr/sfw/bin:/opt/csw/bin:/opt/csw/sbin:/opt/csw/gnu:/opt/csw/mysql5/bin'/>
        </method_environment>
      </method_context>
    </exec_method>
    <exec_method name='stop' type='method' exec=':kill' timeout_seconds='60'>
      <method_context/>
    </exec_method>
    <template>
      <common_name>
        <loctext xml:lang='C'>FogBugz search</loctext>
      </common_name>
    </template>
  </service>
</service_bundle>

Now, import the files into the SMF. When you reboot, they’ll start the daemons for you.

$ sudo svccfg import maintenance.xml
$ sudo svccfg import search.xml

In fact, you should reboot now to make sure everything is running. Use your favorite tools: svcs -vx and ps -ef | grep fog to make sure everything is there.

You might also want to run the diagnostics via your FogBugz web interface.

Help

Mind you, FogCreek’s customer service is superb.

If you, however, have questions about this specific guide, I opened a thread in the forums: http://discuss.joyent.com/viewtopic.php?pid=177397#p177397

Thanks

Many thanks for the countless hours the FogCreek customer support spent with me on the phone and via ssh to sort all the issues I ran into during my first installation.

Thanks to Joyent too for providing a second accelerator where I could practice these install steps and document them.

1) if you use another shell you certainly know which file to edit.
2) FogBugz will later set this anyway, but some PEAR installations will fail with the default 8MB
3) I had these on another accelerator, but didn’t on this one. You may have them already.
4) you could probably curl/wget directly from the server, but since the code is behind some confusing urls, you might prefer to just do it like mere mortals do
 
accelerators/kb/install-fogbugz.txt · Last modified: 2008/04/07 01:20 by cch
 
Recent changes RSS feed Creative Commons License Driven by DokuWiki