Friday, June 27, 2008

mod_rewrite for Apache2 in Ubuntu Feisty Fawn 7.04

This article is originally from Huanix tutorial site

mod_rewrite is a module for the Apache webserver that allows apache to dynamically change the url of a site using php (or other scripting languages). It seems like a difficult/confusing task at first, but it actually only takes 2 steps in Ubuntu. I’m using Feisty Fawn, 7.04, but this should work well for Edgy and Dapper without any issues. Any code snippets should be typed into a terminal. “sudo” commands require a password, that’s a given.

1. Enable mod_rewrite in Apache

sudo a2enmod rewrite

2. Edit the configuration file.

1. sudo gedit /etc/apache2/sites-available/default
2. line 8 and 12 says “AllowOverride none” ;
3. change it to “AllowOverride All”
4. save and close

3. Okay… one last step — you have to manually restart Apache (or restart your computer!)

sudo apache2 -k restart

Happy Coding!!! :)

Installing PHP GD library

Ubuntu installs php without few libraries and here is how to install GD library

sudo apt-get install php5-gd

restart apache

sudo /etc/init.d/apache2 restart

Happy coding :)

Installing Oracle 10g on Ubuntu Feisty

Below instraction is originally from Oracle tutorial site for debian. However, it works with Ubuntu (because ubuntu is from debian) and successfully installed as what below instraction said. There is few area I made modification due to confusion.

+install following packages:
sudo apt-get install gcc make binutils libmotif3 lesstif2 rpm libaio1 libdb3

For post-install configuration login as root
+ create the following groups
--------------------------------------------
via 'System Settings > Users & Groups' or
# sudo groupadd oinstall
# sudo groupadd dba
# sudo groupadd nobody

+ create OS user oracle with group 'oinstall', secondary group 'dba', home /opt/oracle and shell
/bin/bash and set the passwd (make sure you remember this password)
via "System Settings > Users & Groups' or
# sudo useradd -g oinstall -G dba,nobody -d /opt/oracle -s /bin/bash oracle

+ set user oracle's password
# sudo passwd oracle

+ Append user oracle's bash profile with PATH and ORACLE:BASE,HOME and SID information
# vi /opt/oracle/.bash_profile
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_HOSTNAME=
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_PATCH=$ORACLE_HOME/OPatch
export ORACLE_SID=
export ORACLE_TERM=xterm

PATH=$PATH:/usr/sbin
PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH

export PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:.

if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi

+ Create the directory for the software installation and assign ownership to oracle:oinstall
# chown -R oracle:oinstall /opt
# chmod -R 775 /opt

+ Make sure the correct kernel parmeters are appended to sysctl.conf
# vi /etc/sysctl.conf (these can be easily copied from the Quick Installation Guide
for Linux x86 doc on the Oracle10g CD)
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000

+ set the kernel parameters or reboot
# /sbin/sysctl -p

+ set security limits
# vi /etc/security/limits.conf
(and append the following values to the end of the file)
* soft nproc 2047
* hard nproc 16384
* soft nofile 1024
* hard nofile 65536

+ create symbolic links and camoflage Ubuntu to look more like an enterprise rpm based distro,
because the oracle installer is expecting rhel, sles or asianux based distros.
# ln -s /usr/bin/awk /bin/awk
# ln -s /usr/bin/rpm /bin/rpm
# ln -s /lib/libgcc_s.so.1 /lib/libgcc_s.so
# ln -s /usr/bin/basename /bin/basename

Login in to xwindows session as user oracle
-------------------------------------------
+ Mount the Oracle10g CD and run the installer
copy the /media/cdrom/database contents to the hard disk
$ cp -r /media/cdrom/database .
$ cd /database
$ ./runInstaller -ignoreSysPrereqs

As root # vi /etc/oratab change :N to :Y
+ This enables the oracle user to dbshut, dbstart and lsnrctl start

Hope this helps. Happy coding :)

Fast User Switching

Ubuntu Feisty has its own user switching tool and it works pretty good. It just that need to make sure to type the user's password even you don't see the password entry field. I believe it is caused by Compiz utility. However, switching user seems little slugish and found this tutorial from one of Ubuntu tutorial site.

sudo aptitude install fast-user-switch-applet

After that has installed (it’s only 645kB) you simply need to add it to your panel as an applet. You can do that by right-clicking on your panel, selecting “add to panel” and finding “User Switcher” in the Miscellaneous section.

Once this is added you are able to very easily switch between users on the system without completely logging out and logging into another desktop. Simply click on the “Users” icon now appearing on your panel and select another user!

If you have multiple users an your machine, or share the machine with a spouse / roommate / etc this is a really useful little tool. Enjoy!

Happy coding!!!

Installing oci8 on ubuntu 7.04 Feisty

Ubuntu has a simple way to turn into a web server.
To intall...
sudo tasksel install lamp-server

To uninstall...
apache2 apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libdbd-mysql-perl libdbi-perl libmysqlclient15off libnet-daemon-perl libplrpc-perl libpq5 mysql-client-5.0 mysql-common mysql-server mysql-server-5.0 php5-common php5-mysql

However, Ubuntu's LAMP does not include a module for Oracle. So, in order to install oci module do following:
sudo apt-get install php5-dev pear-php

Download the Basic and the SDK packages from http://www.oracle.com/technology/tec...antclient.html. At the time of this writing, the filenames are instantclient-basic-linux32-10.2.0.1-20050713.zip and instantclient-sdk-linux32-10.2.0.1-20050713.zip.

Unzip these files in a new directory, e.g. /opt/oracle/instantclient.
mkdir -p /opt/oracle/instantclient
cd /opt/oracle/instantclient
unzip instantclient-basic-linux32-10.2.0.1-20050713.zip
unzip instantclient-sdk-linux32-10.2.0.1-20050713.zip
echo /opt/oracle/instantclient >> /etc/ld.so.conf
ldconfig

The previous two lines are supposed to create symlinks named libclntsh.so and libocci.so which we will need later. In my case these symlinks were not created by ldconfig, so I created them manually.
ln -s libclntsh.so.10.1 libclntsh.so
ln -s libocci.so.10.1 libocci.so

Next line configure oci8 module for php
pecl install oci8

When installation prompt for instant client lib path, enter below line
'instantclient,/opt/oracle/instantclient'

Last, enter below line on /etc/php5/apache2/php.ini
extension=oci8.so

Hope every thing goes well.

Happy coding