Gallery2:VM-OracleXe - Gallery Codex
Personal tools

Gallery2:VM-OracleXe

From Gallery Codex

VMWare Setup of Ubuntu, Oracle XE and Gallery2

An approach to create an Oracle development testbed for Gallery2 using Ubuntu Server and VMWare.

Setting up the VM Server

The virtual machine requires a minimum of 5GB of disk space and 512MB of memory. Oracle will check when it begins its install and will fail if there is less than 1.5GB of available disk space or if the swap area is not large enough (512MB RAM = 1 GB swap area).

Install Ubuntu Feisty Fawn 7.04

  • Follow the standard installation of Ubuntu server until the partition disks step is reached. At this point choose the manual partitioning method. The defaults don't provide enough swap area to install Oracle.
  • To be safe create a 1.2 GB swap file and the remainder will be primary disk for Ubuntu. Make sure when you create the primary partition, the 'Bootable flag' is set on.
  • Choose the LAMP installation option. It's easier to install the whole package and then remove mysql, than it is to install and configure Apache and PHP.

Software Configuration

  • Logon to the system with user id created during the install.
  • Add this line to /etc/apt/sources.list file:
deb http://oss.oracle.com/debian unstable main non-free
  • Update the apt repository. Replay 'yes' to the prompt related to no public key for oss.oracle.com.
  • Add the following packages: oracle-ex-universal, make, subversion, patch, openssh-server, php5-dev, php-pear, imagemagick, and galley2. It will ask about installing untrusted packages, take the “Really Continue” option as it is referring to the oracle-xe-universal package. The Gallery2 install will ask for some information and taking the defaults is fine. The installer will ask about an old version postgresql-8.1. Just say 'yes'. Say 'no' to restarting apache2.
  • Now that we have everything in place, remove Gallery2, MySql and Postgres. Using aptitude, remove Gallery and then go into the preview and add back the following packages: dcraw, ffmpg, jhead, netpbm, php5-gd, zip and unzip.

Install Gallery

  • Re-install gallery from the svn repository: Change to /usr/share and enter the following command
svn checkout https://gallery.svn.sourceforge.net/svnroot/gallery/trunk/gallery2
  • Edit the /etc/gallery2/apache.conf and uncomment the line.
#Alias /gallery2 /usr/share/gallery2

Configure Oracle

  • Run the following command to configure Oracle:
sudo /etc/init.d/oracle-xe configure
  • Take the defaults when prompted by oracle-xe. This could take a while as the database is configured.
  • Edit your /etc/environment file to include the lines:
ORACLE_HOME=”/usr/lib/oracle/xe/app/oracle/product/10.2.0/server”

PATH=”...:/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin”
ORACLE_SID=”XE”
NLS_LANG=”AMERICAN_AMERICA.UTF8”
LD_LIBRARY_PATH=”/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib”

ORA_NSL10=”/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/nls/data”
  • Edit your /etc/init.d/apache2 file to include the lines:
ENV=“env -i LANG=C”

ENV=”$ENV PATH=”...:/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin”
ENV=”$ENV ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server”
ENV=”$ENV ORACLE_SID=XE”
ENV=”$ENV NLS_LANG=AMERICAN_AMERICA.UTF8”
ENV=”$ENV LD_LIBRARY_PATH=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib”

ENV=”$ENV ORA_NSL10=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/nls/data”
  • Restart the virtual machine so the changes to the /etc/environment will take effect.
  • After the system restarts, logon to the Oracle database as the database administrator:
sqlplus sys as sysdba
  • Enter the following commands:
create user g2user identified by password;

grant connect, resource to g2user;
EXEC DMBS_XDB.SETLISTENERLOCALACCESS(FALSE);
alter system set nls_length_semantics='CHAR';

exit

At this point:

  1. Have a userid that can be used to connect to the database,
  2. The web administrative tool (for creating users / schema /, etc. will be at http://serveraddress:8080/apex/) which can now be accessed from a remote machine, and
  3. The nls_length_semantics i set properly

Install OCI8

  • Type:
sudo pecl install oci8
The 'pecl install oci8' will buld the oci8 libraries. Eventually, it will prompt for the Oracle home directory. If the /etc/environment was changed as described above and the virtual machine restarted, just hit enter.
  • Create /etc/php5/conf.d/oci8.ini file and enter the following
extension=oci8.so

Install XDebug

  • Type:
sudo pecl install xdebug-beta
The 'pecl install xdebug-beta will buld the xdebug libraries.
  • Create /etc/php5/conf.d/xdebug.ini file and enter the following, where xxxxx could be anything, on my machine it was 20060613+lfs.
zend_extension=/usr/lib/php5/xxxxx/xdebug.so
  • Restart apache.

Note: I wouldn't recommend installing XDebug, if you are planning to run the entire unit test suite. It seems to grab and keep storage. In one run, after 700 tests, Apache had allocated 1.5GB of virtual memory and each test was taking about 5 minutes to run. After removing XDebug the tests completed in a normal amount of time.

Testing the Installation

  • Create a index.php in /var/www/apache2-default and enter the following line.
<?php print phpinfo(); ?>
OCI8 should be displayed as a registered extension and the xdebug will show in the same block as the Zend2 icon is.

Test Oracle Installation

  • Create the following php script in /var/www/apache2-default
<?php

$oracle = oci_connect(’username’, ‘password’, ‘//localhost/XE’);
if (!$oracle) {

$e = oci_error();
print htmlentities($e[’message’]);

} else {

print 'oracle is set up correctly.';

}

?>
When this is run from a browser, the page should show oracle is set up correctly..

Installation Troubleshooting

The directory /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/config/log contains the logfiles of the sql scripts run to initially set up the database. If you are having problems with oracle not starting up, check these files.

Gallery Configuration

  • Follow the normal Gallery2 installation process.
  • When prompted by the Gallery installation, enter the following information for the Oracle database setup. The database must be 'XE'.
Database type: Oracle (9i and newer)
DB Hostname: localhost
DB Username: userid created above
DB Password: password
DB Name: XE
Table Prefix: g2_
Column Prefix: g_
advertisements