There are many posts on how to set the required environment variables, namely ORACLE_HOME, after the installation of Oracle 11g Express Edition (XE). They usually tell you to change some init scripts for bash (e.g. ~/.bashrc or ~/.bash_profile). While this is a possible approach, it is more complicated than necessary and certainly not elegant.
CentOS/RHEL has a nice mechanism to add environment variables on a global basis and separately for different programs. Just check out this directory:
/etc/profile.dEach file in there sets the environment variables for just a single program, so things are kept nicely separated. The files are just normal shell scripts with regard to syntax and do not need to be executable.
And since Oracle 11g XE has already created a file with exactly the right content as part of the installation, it is just enough to create a symlink from /etc/profile.d to this file.
ln -s /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh /etc/profile.d/Just login to another shell session and check the environment variables with set. You should see, among other variables, the following values
NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1Hope that helps!
1 thought on “Oracle 11g XE: Setting Environment Variables on CentOS/RHEL”
In this post, there is a PL/SQL script that generates current database environment file.
Also, it contains a good example of an environment file you’d better use for your database.