LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to define Environmental Variables in Suse (https://www.linuxquestions.org/questions/linux-software-2/how-to-define-environmental-variables-in-suse-446061/)

khairkhoah 05-18-2006 09:10 AM

How to define Environmental Variables in Suse
 
Hello,

I am new to Linux. I have downloaded the binaries for Apache 2 and Tomcat 5 and want them to start automatically when the computer starts. When I start these processes, I do not see an entry in the Services so I cannot configure them using Yast2 in 'System Services'. I read some where that I can do by defining the entries in /etc/skel/.profile or /etc/skel/.bashrc. I did make the enteries in both of them but it still doesnt work. In addition to this I also tried to configure the JAVA_HOME and JRE_HOME environmental variables in .bashrc and .profile file but that also didnt work :confused: . Here are the entried that I made

export JAVA_HOME=/home/ahayat/jdk1.5.0_06/
export JRE_HOME=/home/ahayat/jdk1.5.0_06/jre

/usr/sbin/rcapache2 startssl
/etc/apache-tomcat-5.5.17/bin/startup.sh

Am I making a mistake here?

Regards.

sharp81 05-18-2006 09:21 AM

you need to set those variables in etc/profile .... and maybe do a restart of the computer or sometimes just loggin out and logging back in will work ..

Sharp

Nylex 05-18-2006 09:24 AM

After adding to your .bashrc, did you remember to run "source .bashrc"?

manishsingh4u 05-18-2006 09:41 AM

Quote:

Originally Posted by sharp81
you need to set those variables in etc/profile

Yes, this is the best way to initialize environment variables.
But, for the apache scripts to run automatically at start up, you must add them to your boot.local file.

khairkhoah 05-18-2006 09:42 AM

Quote:

Originally Posted by Nylex
After adding to your .bashrc, did you remember to run "source .bashrc"?

I ran source .bashrc and it started the services. But do I have to do it manually or can I define it to run automatically?

Regards.

khairkhoah 05-18-2006 09:45 AM

Quote:

Originally Posted by manishsingh4u
Yes, this is the best way to initialize environment variables.
But, for the apache scripts to run automatically at start up, you must add them to your rc.local file.

I looked at /etc/profile and it says in the file

[
# PLEASE DO NOT CHANGE /etc/profile. There are chances that your changes
# will be lost during system upgrades. Instead use /etc/profile.local for
# your local settings, favourite global aliases, VISUAL and EDITOR
# variables, etc ...


And I could not find a profile.local file. Do I need to create one? Also the file /etc/profile looks complex, if at all I have to make the entries into it then how do I do it?

Regards.

Nylex 05-18-2006 09:47 AM

The .bashrc file will be sourced every time you start your machine, you just need to resource it when you make changes.

You probably should put the lines for your services in your /etc/rc.d/rc.local (or equivalent, I'm not sure if this is standard to all distros) instead of .bashrc.

manishsingh4u 05-18-2006 09:53 AM

Well, u have to add those two export statements at the end of the /etc/profile file. You don't have to change anything else. I have used Tomcat with the same method. It worked fine.
Quote:

And I could not find a profile.local file
I didn't mention any such file. Initially, I had written rc.local as it is a standard for most of the distros. But later, I changed it to boot.local as there's no rc.local in SUSE.

khairkhoah 05-18-2006 10:01 AM

Quote:

Originally Posted by Nylex
The .bashrc file will be sourced every time you start your machine, you just need to resource it when you make changes.

You probably should put the lines for your services in your /etc/rc.d/rc.local (or equivalent, I'm not sure if this is standard to all distros) instead of .bashrc.

What do you mean by 'resource it when you make changes'? Does it mean to run the command source .baschrc

There is no rc.local file but I looked at the rc file but couldnt figure out how to add new lines.

Do I add them like this

test -s /usr/sbin/rcapache2 startssl || RUN_PARALLEL="no"

or do I have to enclose it between if and fi?

Regards.

manishsingh4u 05-18-2006 10:07 AM

My appologies. you can add these commands to
Code:

/etc/init.d/boot.local

Nylex 05-18-2006 10:45 AM

Quote:

Originally Posted by khairkhoah
Does it mean to run the command source .baschrc

Yep.

Quote:

There is no rc.local file but I looked at the rc file but couldnt figure out how to add new lines.

Do I add them like this

test -s /usr/sbin/rcapache2 startssl || RUN_PARALLEL="no"

or do I have to enclose it between if and fi?

Regards.
Not sure about this.

khairkhoah 05-19-2006 03:42 AM

Finally it worked.

On the first computer I was trying every thing so I made the changes in .bashrc, boot.local, /etc/profile :). When I rebotted the computer, both Apache and Tomcat were running but I can't really say which change actually did make them work. So then I went on another computer running Suse 10 and made the changes only in the boot.local file and could see that both Apache and Tomcat are running fine.

So what I have learnt is that there are several ways of doing it. I can either do it through boot.local file, or make the changes in .baschrc file and then resource it.

Regarding etc/profile, is this file used only to define environmental variables like JAVA_HOME etc. or can it also be used to start services like Apache etc.?

Thanks for the help.

Regards.

manishsingh4u 05-19-2006 06:25 AM

Quote:

Originally Posted by khairkhoah
Regarding etc/profile, is this file used only to define environmental variables like JAVA_HOME etc. or can it also be used to start services like Apache etc.?

Well, as per my experience, you can not use /etc/profile for starting services. If anyone has done this, I am interested to learn that.

khairkhoah 06-05-2006 07:08 AM

I have one other question. How can I define environmental variable so that I do not have to type path along with executable files. For instance to start Tomcat I type this /etc/apache-tomcat/bin/startup.sh whereas I would like to just type startup.sh and it should start the Tomcat server.

Thanks for the help.

manishsingh4u 06-05-2006 09:19 AM

Quote:

Originally Posted by khairkhoah
I would like to just type startup.sh and it should start the Tomcat server.

add this line to your /etc/profile
Code:

export PATH=$PATH:/etc/apache-tomcat/bin


All times are GMT -5. The time now is 02:11 AM.