Oracle Database 11g Release 2 + Apache 2.2 + PHP5.3 on Debian Squeeze HOWTO (Part 2)

This HOWTO will guide you though installing Oracle Database 11g Release 2 + Apache2.2 + PHP5.3 on Debian Squeeze.

But why we need this HOWTO? Since Oracle only officially support Red Hat Enterprise Linux, SUSE Enterprise Linux and other enterprise level Linux distribution; BTW, there shouldn't be any problem if you hope to use with other distribution, which just need some special configuration and install required dependent packages.

Before start you will need to prepare your Debian with:

  • A complete Debian Squeeze installation with X11.
  • Static public IP address (or you may bind to localhost during installation).
  • Functional hostname, e.g. hardcode it within /etc/hostname and /etc/hosts.

In case of Debian Squeeze you don't need to install too much package by default, but I would like to recommand at least install "SSH server" and "Standard system utilities" during installation, after reboot install a very basic X11 + Gnome as below:

apt-get install gnome-core xorg iceweasel

Then test your X11 with startx ;-)

Check your hardware setup

First of all, you need to have AT LEAST 1GB of physical memory (I use 2GB here). Check it with:

grep MemTotal /proc/meminfo

On the other hand, it is suggest to have swap with 1.5 time of your physical memory, e.g. around 2GB. Check it with:

grep SwapTotal /proc/meminfo

In case I am using libvirt + KVM VM client, I don't hope to create swap partition by default or else if all VMs are running out of resourse they will all keep on swapping to harddisk and finally all gone...

Here I will create a temperate swap file and activate it during installation; once reboot it will gone automatically (or manually disable it with swapoff /tmp/swap):

dd if=/dev/zero of=/tmp/swap bs=1M count=4096
chmod 600 /tmp/swap
mkswap /tmp/swap
swapon /tmp/swap

Shared memory is very important, too. Or else you may face the ORA-00845 error message. First check it with:

df -kh /dev/shm/

If you have less than 512MB (I will suggest for 1GB), edit your /etc/fstab and add/modify the following line:

tmpfs           /dev/shm        tmpfs   defaults,size=1024M    0       0

Then remount it and check the size once again:

mount -o remount /dev/shm
df -kh /dev/shm/

Prepare network connection

Oracle 11g is highly depend on a correct network connection setup, especially the hostname and domain must be a valid value. On the other hand, I will suggest bind your Debian as localhost only, so you will even able to migrate the installation to other IP without reconfigure the Oracle installation.

Configure your /etc/hostname as below. Be careful that you MUST have a valid domain name (e.g. localdomain):


Also make sure your /etc/hosts have this line: localhost.localdomain localhost 

Install dependence packages

As I assume you have Debian squeeze installed correctly with X11, we just need to dig into dependence packages installation directly (in case of AMD64):

apt-get install alien binutils build-essential cpp-4.4 debhelper g++-4.4 gawk gcc-4.4 gcc-4.4-base gettext html2text ia32-libs ia32-libs-dev intltool-debian ksh lesstif2 libaio-dev libaio1 libbeecrypt7 libc6 libc6-dev libc6-dev-i386 libdb4.8 libelf-dev libelf1 libltdl-dev libltdl7 libmotif4 libodbcinstq1c2 libqt4-core libqt4-gui libsqlite3-0 libstdc++5 libstdc++6 libstdc++6-4.4-dev lsb lsb-core lsb-cxx lsb-desktop lsb-graphics lsb-qt4 make odbcinst pax po-debconf rpm rpm-common sysstat unixodbc unixodbc-dev unzip

System groups and users

Check your existing setup with:

grep oinstall /etc/group
grep dba /etc/group
grep nobody /etc/group
id oracle
id nobody

Most likely, you should run the following command for create the required system groups and users. Latest Debian sid already come with user nobody so we don't need to retouch it:

addgroup --system oinstall
addgroup --system dba
useradd -r -g oinstall -G dba -m -s /bin/bash -d /var/lib/oracle oracle
passwd oracle

Configure kernel parameters

Check your existing setup with:

/sbin/sysctl -a | grep sem
/sbin/sysctl -a | grep shm
/sbin/sysctl -a | grep file-max
/sbin/sysctl -a | grep ip_local_port_range
/sbin/sysctl -a | grep rmem_default
/sbin/sysctl -a | grep rmem_max
/sbin/sysctl -a | grep wmem_default
/sbin/sysctl -a | grep wmem_max

Then edit your /etc/sysctl.conf and add the following lines:

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586

Run the following command to reload these kernel parameters:

sysctl -p 

Shell limits for oracle user

Add the following to /etc/security/limits.conf as below:

oracle              soft    nproc   2047
oracle              hard    nproc   16384
oracle              soft    nofile  1024
oracle              hard    nofile  65536
oracle              soft    stack   10240

Check (or add) if the following line exits within /etc/pam.d/login:

session required /lib/security/ 

Check (or add) if the following line exits within /etc/pam.d/su:

session required 

Add this lines to the tail of /etc/profile:

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

Create required directories

Create required directory and change permission:

mkdir -p /u01/app/oracle
mkdir -p /u02/oradata
chown -R oracle:oinstall /u01 /u02
chmod -R 775 /u01 /u02

Configuring the oracle user's environment

Add following line to /var/lib/oracle/.profile (as i will create a AL32UTF8 database; change to US7ASCII if you will create ASCII database). This will also map Oracle's /bin to your $PATH so can run Oracle's binary directly when login as user oracle:

umask 022
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export NLS_LANG=.AL32UTF8
if [ -d "$ORACLE_HOME/bin" ]; then

Fake Oracle installer

As mentioned before , Debian is not listed as Oracle officially support platform and so we need to "fake" it. Create symbolic links:

mkdir /usr/lib64
ln -s /etc /etc/rc.d
ln -s /lib/x86_64-linux-gnu/ /lib64/
ln -s /usr/bin/awk /bin/awk
ln -s /usr/bin/basename /bin/basename
ln -s /usr/bin/rpm /bin/rpm
ln -s /usr/lib/x86_64-linux-gnu/libc_nonshared.a /usr/lib64/
ln -s /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a /usr/lib64/
ln -s /usr/lib/x86_64-linux-gnu/ /lib64/
ln -s /usr/lib/x86_64-linux-gnu/ /usr/lib64/
ln -s /usr/lib/x86_64-linux-gnu/ /lib64/
ln -s /usr/lib/x86_64-linux-gnu/ /usr/lib64/

Also mask ourself as RedHat:

echo 'Red Hat Linux release 5' > /etc/redhat-release

Last step before installation start

First of all, login with your new oracle user, with X enabled.

If you are using PuTTY + Xming, for sure that the X11 forward is enabled.

Copy the file to oracle's home directory, then unzip it:

cp /var/lib/oracle
cp /var/lib/oracle
cd /var/lib/oracle
unzip -q
unzip -q

I will STRONGLY suggest for a complete reboot, and double-check ALL pre-installation BEFORE starting the next step.

First of all login with useraccount "oracle" and start the X11 with startx, then start the installer with:

cd /var/lib/oracle/database && ./runInstaller 

Next we go though the installation (I don't have the "Oracle Support Password" so just skip in here):

In "Selection Installation Option", choose "Create and configure a database":

In "System Class", choose "Server Class" (we hope to give a full control during installation):

In "Node Selection", choose "Single instance database installation":

In "Select Install Type", choose "Advanced install":

In "Select Product Languages", I choose to install all available languages:

In "Select Database Edition", I choose "Enterprise Edition":

In "Specify Installation Location", it should default as below:

  • Oracle Base: /u01/app/oracle
  • Sofeware Location: /u01/app/oracle/product/11.2.0/dbhome_1

In "Create Inventory", it should default as below:

  • Inventory Directory: /u01/app/oraInventory
  • oraInventory Group Name: oinstall

In "Select Configure Type", choose "General Purpose / Transaction Processing":

(IMPORTANT!) In "Specify Database Identifiers", configure as below:

  • Global database name: AL32UTF8.localdomain
  • Oracle Service Identifier (SID): AL32UTF8

In "Specify Configuration Options", configure as below:

  • Memory -> Enable Automatic Memory Management: TRUE
  • Character sets: Use Unicode (AL32UTF8)

In "Specify Management Options", choose "Use Database Control for database management" but keep other else empty:

In "Specify Database Storage Options", choose "File System" where:

  • Specify database file location: /u01/app/oracle/oradata

In "Specify Recovery Options", choose "Do not enable automated backups":

In "Specify Schema Passwords", I am a bit lazy so choose "Use the same password for all accounts" (don't do this in production server!):

In "Privileged Operating System Groups", confirm as below:

  • Database Administrator (OSDBA) Group: dba
  • Database Operator (OSOPER) Group: oinstall

In "Preform Prerequisite Checks", just simply ignore all warning message (since we are using Debian but not Oracle officially supported OS):

So just confirm everything in "Summary":

And now let's go for a coffee break ;-)

Oh it should that almost done!

Special note for Debian Wheezy: If you face error during installation, please open "/u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib/", search for below pattern:


And replace as:

        $(MK_EMAGENT_NMECTL) -lnnz11

Then keep ongoing for installation ;-)

Now following the instructions and run the following commands with "root" user:

  • /u01/app/oraInventory/
  • /u01/app/oracle/product/11.2.0/dbhome_1/

Ok you get it!

Confirm with installation progress

In previous screen the installer mentioned that we can access "Enterprise Manager Database Control URL - (AL32UTF8)" from https://localhost.localdomain:1158/em, so now let's open the browser and test it with following account:

  • User Name: SYS
  • Password: your_secret_password
  • Connect As: SYSDBA

Once login it should show as below:

Autostart Oracle during system boot

There is almost for sure that you will hope to start your Oracle automatically during system boot. Even you may turn this feature off, but the init.d script is very useful, too.

First of all, specify which database instant will be started together with Oracle. Edit /etc/oratab as below:


Next, create init.d script as /etc/init.d/oracle:

# Run-level Startup script for the Oracle Instance and Listener
# chkconfig: 345 91 19
# description: Startup/Shutdown Oracle listener and instance


# if the executables do not exist -- display error

if [ ! -f $ORA_HOME/bin/dbstart -o ! -d $ORA_HOME ]
        echo "Oracle startup: cannot start"
        exit 1

# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display

case "$1" in
                # Oracle listener and instance startup
                echo -n "Starting Oracle: "
                su - $ORA_OWNR -c "$ORA_HOME/bin/dbstart $ORA_HOME"
                su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl start"

                #Optional : for Enterprise Manager software only
                su - $ORA_OWNR -c "$ORA_HOME/bin/emctl start dbconsole"

                touch /var/lock/oracle
                echo "OK"
                # Oracle listener and instance shutdown
                echo -n "Shutdown Oracle: "

                #Optional : for Enterprise Manager software only
                su - $ORA_OWNR -c "$ORA_HOME/bin/emctl stop dbconsole"

                su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl stop"
                su - $ORA_OWNR -c "$ORA_HOME/bin/dbshut $ORA_HOME"
                rm -f /var/lock/oracle
                echo "OK"
                $0 stop
                $0 start
                echo "Usage: $0 start|stop|restart|reload"
                exit 1
exit 0

Permission is very important, too:

chmod 755 /etc/init.d/oracle

Finally, install the script so Oracle will start during system bootup:

update-rc.d oracle defaults 99 01

NOTE: You may find the following error message during /etc/init.d/oracle/stop:

Shutdown Oracle: ulimit: 25: bad number

You can then update /u01/app/oracle/product/11.2.0/dbhome_1/bin/emctl with #!/bin/bash to solve the problem:

#!/bin/bash -f


admin's picture

sudo ln -s /usr/lib/x86_64-linux-gnu /usr/lib64
sudo ln -s /lib/x86_64-linux-gnu /lib64
However there are still some errors but the database can start.

hswong3i's picture
Already update some step as refer to Wheezy requirement ;-)
admin's picture

Worked! Thank you!

admin's picture

thanks for existing

Michal's picture

Great tutorial, worked for me!

Fábio Rabelo's picture

Just installed on Squeeze, works fine in the first attempt ...

Wil try on Wheezy soon ...

Fábio Rabelo De Deus's picture

Wheezy uses a new approach to i32 libs, and to solve this, before install dependencies, you need to to this :

dpkg --add-architecture i386
apt-get update

Fábio Rabelo De Deus's picture

I am getting an error in y just instaled Oracle 11gR2 in Debian Wheezy .

It complains about ulimits :

/bin/sh: 1: ulimit: Illegal option -u

Some clue ?!?

Aparently it is working ( at least tnslsnr are up )

Fábio Rabelo De Deus's picture

OK, I just saw another error during boot-up .

Every Oracle instance that are started shows a line like this :

/etc/profile : line 43 : ulimits : open files : cannot modify limits : operation not permitted

And, during shutdown, this errors appears every oracle instance that shuts down

/u01/app/oracle/product/11.2.1/dbhome_1/bin/emctl 23 : ulimit : bad number

stiils no clue

Hery Paslie's picture

How to install oracle 12c coins debian 7.6.0 64Bits

Add new comment

Restricted HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <h4> <h5> <h6>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • HTML tags will be transformed to conform to HTML standards.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.