Friday 24 October 2008

How I got php with oci8 working

  1. Install Oracle instant client (the basic package and the SDK!). (You obviously need the 64bit version on a 64bit architecture). I tried doing this using my locally installed oracle express edition (XE) but that whas a whole lot of pain:
    OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory
    I ended up using oracle_instantclient_10_2 which worked!!
  2. sudo -i
  3. apt-get install apache2 php5 php5-dev php-pear libaio1
  4. Make sure your $ORACLE_HOME and $LD_LIBRARY_PATH is set. Since I have 2 different versions of 'oracle' I set these two variables in /usr/sbin/apache2ctl, at the top of the 'CONFIGURATION SETION':
    export ORACLE_HOME=/stuph/install/oracle_instantclient_10_2
    export LD_LIBRARY_PATH=$ORACLE_HOME
  5. echo $ORACLE_HOME >> /etc/ld.so.conf
  6. ldconfig
  7. Check if the symlinks named libclntsh.so and libocci.so exist in $ORACLE_HOME, which we will need later. In my case these symlinks were not created by ldconfig, so I created them manually:

    ln -s libclntsh.so.11.1 libclntsh.so; ln -s libocci.so.11.1 libocci.so

  8. pecl install oci8
  9. To enable the oci8 module, add "extension=oci8.so" to /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini). (put this line after the examples starting with ; in the "Dynamic Extensions" section).

  10. ldconfig
  11. apache2ctl restart
    (or
    /etc/init.d/apache2 force-reload
    to make sure)
  12. You should see the oci8 module in the output of phpinfo(). (put info.php in ~www-data or ~apache with the following content and browse to it: "<? phpinfo() ?>")

(I'm sorry if this assumes you know how to do certain stuff, but this is a howto for myself, so that I can remember how to do this in a mounth's time)

Saturday 11 October 2008

my bash setup

Here are some things I put in ~/.bashrc or /etc/bash.bashrc to make my life easier:

# When using bash, I use ctrl+r a lot to find commands I executed recently.
# I found that I remember my commands for much longer than bash does,
# so I increased my bash's memory:
export HISTFILESIZE=3000 # the bash history should save 3000 commands
export HISTCONTROL=ignoredups # don't put duplicate lines in the history.
export HISTCONTROL=ignoreboth # ignore same sucessive entries.
# (from http://www.novell.com/coolsolutions/tools/17142.html)

# I like to have a colour prompt with my user, the machine I'm on and the full
# path. Its a bit long so I put it on 2 lines.
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;33m\]\w\[\033[00m\]>\n\$ '

# enable bzr command auto completion
. /opt/bzr/bzr.current/contrib/bash/bzr.simple

# bzr aliasses
alias bt='./bzr --no-plugins selftest'
alias bd='bzr diff'
alias bl='bzr log'
alias bp='bzr pull -v |less'
alias bm='bzr missing |less'
alias bs='bzr status'

# bzr functions, which cant be done by alias or bzr's alias
bh(){
#the $@ inserts all the parameters you pass in
bzr help "$@" |less
}

bcd(){
bzr cdiff "$@" | less -R
}

Sunday 5 October 2008

Super cool startup script for linux

I recently had to get a startup script going which works on Ubuntu and Sles for loggerhead. I came up with these install instructions and following simple but super cool init script. Note that this should work for basically any linux daemon, you just need to rename the script (loggerheadd) and change the script a little.
  1. Copy loggerheadd to /etc/init.d
  2. Edit the file to configure it.
  3. Register the service:
    cd /etc/init.d
  • on upstart based systems like Ubuntu run:
    update-rc.d loggerheadd defaults
  • on Sysvinit based systems like Centos or SuSE run:
    chkconfig --add loggerheadd

Here follows the script (the indentation is a bit messed up by blogspot)

#!/bin/sh
### BEGIN INIT INFO
# Required-Start: $local_fs $remote_fs $network
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Loggerhead
# Description: Manage Loggerhead (a web viewer for projects in bazaar)
### END INIT INFO

# Configure this please: #
LOGGERHEAD_PATH=/opt/loggerhead
LOG_FOLDER=/var/log/loggerhead
LOG_FILE=$LOG_FOLDER/loggerheadd.log
PREFIX=/loggerhead
PORT=8080

# You can add additional options to serve-branches here:
START_CMD="$LOGGERHEAD_PATH/serve-branches --prefix=$PREFIX --log-folder=$LOG_FOLDER --port=$PORT /var/lib/gforge/bzrroot/"

#
# main part
#
case "$1" in
start)
python $START_CMD > $LOG_FILE 2>&1 &
echo "Started loggerhead. (See $LOG_FOLDER for details.)"
;;
stop)
pkill -f "$START_CMD"
;;
status)
proccess=`pgrep -fl "$START_CMD"`
echo "$proccess"
netstat -anp |grep -e ":$PORT"
if [ -z "$proccess" ]; then
echo "Loggerhead is not running."
else
echo "Loggerhead is running."
fi
;;

*)
echo "Usage: loggerheadd { start | stop | status }"
exit 1
esac

Wednesday 1 October 2008

Maximum file sizes on differrent file systems

I was looking up the maximum file size on a file system for a friend, and I realised I didn't even know this stuff. Here is a couple:
FAT32: 4 GiB
NTFS: 16 EiB
ext2 and ext3: 16 GiB to 2 TiB (see this note about max range)
ext4: 1 EiB
ReiserFS: 8 TiB
HFS plus (used by Apple's Mac OS X): 8 EiB

http://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits