Wayne Khan

Web developer musings… and then some.

Oneiric Ocelot

on January 19, 2012

Since Ubuntu is released every six months, I’ve compiled a set of instructions/shell commands to get my development environment up ASAP. This one references packages applicable to 11.10 (Oneiric Ocelot). If you use a different one, your mileage will differ!

~/.bashrc

# Android.
export PATH=${PATH}:~/android-sdk-linux/tools:~/android-sdk-linux/platform-tools

# Oracle.
alias sqlplus=’rlwrap sqlplus’
. /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh
export TNS_ADMIN=${ORACLE_HOME}/network/admin

# Text editor.
export VISUAL=/usr/bin/vim

~/.screenrc

# ~/.screenrc

defscrollback 10240
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'
startup_message off
vbell off

screen -t root 0
screen -t bash 1
screen -t mysql/sqlplus 2
screen -t vim 3

Package management

Oneiric ships with — in my opinion only, of course — too many packages, so customize (or completely exclude) the apt-get remove, apt-get install sections as required.

sudo apt-get remove aisleriot quadrapassel gbrainy gnome-games-common gnome-mahjongg libreoffice-* gnome-sudoku gnomine -y; \
sudo apt-get autoremove -y; \
sudo apt-get update; \
sudo apt-get upgrade -y; \
sudo apt-get install barcode git-core git-doc git-gui gnome-do imagemagick libaio1 libapache2-mod-php5 meld mysql-server phpmyadmin php-pear php5 php5-cli php5-curl php5-dev php5-ffmpeg php5-gd php5-imagick php5-mcrypt php5-mysql php5-xdebug rlwrap ruby ruby-dev screen subversion tidy vim vim-gnome xclip -y --fix-missing;

Git

ssh-keygen -t rsa
xclip -sel clip < ~/.ssh/id_rsa.pub


; ~/.gitconfig

[alias]
ci = commit
di = diff
st = status

  1. Paste the copied public key into the “Public keys” section of your git repository provider.
  2. ~/.gitconfig creates Subversion-like aliases.

Apache

The recommended method to serve PHP pages is via mod_userdir; i.e. a public_html/ from the user’s home directory; e.g. /home/kzhiwei/public_html/. The following commands enable mod_rewrite and mod_userdir.

sudo a2enmod rewrite; \
sudo a2enmod userdir;

  1. Define ServerName in /etc/apache2/httpd.conf; e.g. “localhost”.
  2. Update AllowOverride in /etc/apache/mods-available/userdir.conf to “AllowOverride All”, so URL rewriting, .htaccess files work correctly.
  3. If using CakePHP with mod_rewrite, the default .htaccess files will not working correctly. Use RewriteBase to adjust accordingly; e.g. for http://localhost/~kzhiwei/github.com/kzhiwei/sandbox/ to work correctly; e.g.
    • /.htaccess: RewriteBase /~kzhiwei/github.com/kzhiwei/sandbox/
    • /app/.htaccess: RewriteBase /~kzhiwei/github.com/kzhiwei/sandbox/app/
    • /app/webroot/.htaccess: RewriteBase /~kzhiwei/github.com/kzhiwei/sandbox/app/webroot/
  4. Update /etc/apache2/mods-available/php5.conf by commenting “php_admin_value engine Off”, so PHP in user-directories work correctly.
  5. Issue ‘sudo service apache2 restart’ when done.

~/.vimrc

"~/.vmrc

"Basics.
colorscheme koehler
set autoindent
set nowrap
set ruler
syntax on

"Tabs, not spaces.
set shiftwidth=3
set softtabstop=3
set tabstop=3

"Others.
set directory=/tmp "Place swap files in /tmp.
set hidden "Switch between unsaved buffers. Beware :q!.
set ignorecase "Case-insensitive text search...
set smartcase "... unless specified.
set term=xterm "PuTTY/Command-T compatibility.

Command-T plugin for Vim

Command-T is the one plugin I use. For working with large code bases with multiple files, it helps me open multiple buffers quickly, with a couple of keystrokes. My explanation doesn’t do it much justice, you have to give it a try yourself. If it’s the only new thing you try in 2012, this is it!

wget http://www.vim.org/scripts/download_script.php?src_id=15560 -O ~/command-t.vba; \
vim ~/command-t.vba;

Command-T is distributed as a “vimball” which means that it can be installed
by opening it in Vim and then sourcing it.

:e command-t.vba
:so %

Next the C extension is built from the shell:

cd ~/.vim/ruby/command-t/; \
ruby extconf.rb; \
make;

Assuming make is successfully, the next time you open Vim you’ll be able to use the Leader key — defaults to backslash (/) — to summon Command-T. Thereafter, inputting the path/name of the file you’re interested in, then hit Enter to open.

Oracle Express Edition (XE)

wget http://oss.oracle.com/debian/dists/unstable/non-free/binary-i386/oracle-xe-universal_10.2.0.1-1.1_i386.deb; \
sudo dpkg -i oracle-xe-universal_10.2.0.1-1.1_i386.deb; \
sudo /etc/init.d/oracle-xe configure; \
. /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh; \
sudo pecl install oci8; \
sudo touch /etc/php5/conf.d/oci8.ini;

  1. When prompted to provide the path to the ORACLE_HOME directory, use ‘/usr/lib/oracle/xe/app/oracle/product/10.2.0/server’.
  2. Using oracle_env.sh to define Oracle-related environment variables mostly works correctly, except two naggy “[[: not found” errors. This can be resolved by editing lines 108, 110 of /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/nls_lang.sh and removing the extra set of brackets.
  3. Add “extension=oci8.so” to /etc/php5/conf.d/oci8.ini.
  4. Add “export LD_LIBRARY_PATH=’/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib:’; export ORACLE_HOME=’/usr/lib/oracle/xe/app/oracle/product/10.2.0/server’” to /etc/apache2/envvars so that Oracle works correctly in PHP.
  5. In case “pecl install oci8″ fails, check if php5-dev, php-pear is installed.
References

Command-T : Fast file navigation for VIM
Oracle and PHP5 in Debian-like systems

Advertisement

2 Responses to “Oneiric Ocelot”

  1. eddie t. says:

    how’s Ubuntu 11 working out for you? Thinking of trying as well.

  2. Wayne Khan says:

    Ubuntu has been excellent since, I think 8.04 onwards. You’ll want to get the Long Term Support (LTS) version; i.e. 11.04 since they’re supporting it for 3 years. If you get 11.10; i.e. Oneiric Ocelot there’ll be frequent updates yup.

    Anyways, the next stable one (12.04) is coming soon (April), so you can hold out for awhile.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.