Koozali.org: home of the SME Server
Obsolete Releases => SME 7.x Contribs => Topic started by: edb on September 09, 2007, 07:20:40 AM
-
Does anyone know how I can create a system environment variable?
I had this working in SME6x by adding two lines to /etc/init.d/httpd file in the section below start() { of the httpd file.... like this:
# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure. So we just do it the way init scripts
# are expected to behave here.
start() {
my_variable=/home/e-smith/files/ibays/store
export my_variable
echo -n $"Starting $prog: "
daemon $httpd `moduleargs` $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
return $RETVAL
}
stop() {
The two added lines set the variable that tells my one website where to find it's custom files.
I had this working in SME6x by directly editing the "httpd" file but I can't seem to reproduce this in SME 7.2 , I believe because "/etc/init.d/httpd" is no longer available and is replaced by "/etc/init.d/httpd-e-smith". When I try to edit the "httpd-e-smith" file the same way I did with the "httpd" file in SME-6x it doesn't seem to work or give me the same result.
I just cannot seem to get this working in SME7.2 .... I understand that there may be other ways to accomplish setting this system variable which is necessary for one of my websites?
If someone knows of an alternate way I would be greatful.
Any advise is welcome.
Thanks
edb
-
Still looking for some assistance on this issue but what I have discovered is that if I modify the /etc/httpd file then shut down /etc/init.d/httpd-e-smith stop and do a /etc/init.d/httpd start I then have the results I'm looking for as far as adding the system variable through the httpd file.
What I want to simply be able to accomplish is the same result but by using the /etc/init.d/httpd-e-smith file which is the way e-smith was designed to start Apache.
Is there a template that I could create or something becuase a direct modify of the /etc/init.d/httpd-e-smith file for some reason doesn't add the variable as it does when I modify the /etc/init.d/httpd file.
Hope you can make sense of what I saying as I'm trying to be as clear as I can.
Maybe Charlie could shed some light if he's watching this thread.
Any help appreciated.
-
Have you had a look at the dev guide ?
http://wiki.contribs.org/SME_Server:Documentation:Developers_Manual
-
Thanks Byte
Yes I looked at it, but nothing in there helps me with my specific question or I'm not smart enough to find what I'm supose to be looking for but either way it doesn't help.
-
I just cannot seem to get this working in SME7.2 .... I understand that there may be other ways to accomplish setting this system variable which is necessary for one of my websites?
If someone knows of an alternate way I would be greatful.
Any advise is welcome.
It is not quite clear to me whyt you tried to solve things like this, perhaps you can explain your situation a bit more. What is your goal for instance?
Perhaps we can template your solution in the configuration file of the server, which will also make it portable over upgrades and updates...
-
Hi cactus,
My situation is that I have a custom ecommerce site where the third party programmer designed the software to use a system variable to define the path of where to find the applications files. Whithout this system variable defined it will not work.
The way we got it working in SME6x was by adding two lines to /etc/init.d/httpd file in the section below start() { of the httpd file.... like this:
# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure. So we just do it the way init scripts
# are expected to behave here.
start() {
STORE_BASE=/home/e-smith/files/ibays/store
export STORE_BASE
echo -n $"Starting $prog: "
daemon $httpd `moduleargs` $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
return $RETVAL
}
stop() {
The two added lines set the variable that tells my ecommerce website where to find it's custom config files.
I wrote a simple info.php script to obtain the two reqired variables if things are working properly I should get a value returned for
Here is the info.php file I made to test if the variable is present.
start of file ----------
<body bgcolor="rgb(210,160,95)"
<strong>This php script is to echo out the two necessary STORE variables to confirm that they are set as required.</strong></br></br>
<div>Server Name =
<td><strong><?php echo $_SERVER['SERVER_NAME'] ?></strong></td></div></br>
<div>STORE Base Directory =
<td><strong><?php echo getenv('STORE_BASE') ?></strong></td></div></br></br>
<font color=red <strong>If you not conficts between what is shown here and where you have your STORE files located you will need to correct this before continuing!</strong></font>
</bgcolor></br></br>
End of file -------------
The results displayed by this php file should indicate the
Server Name = www.mycompany.com
STORE Base Directory = /home/e-smith/files/ibays/store
This is all I'm trying to accomplish.
Thanks for helping ...
edb
-
I think you are far better of using the SET_ENV (http://httpd.apache.org/docs/2.2/mod/mod_env.html#setenv) command in the apache configuration
You probably defined a configuration template for your application of is it running in an ibay?
Anyway we need to make a configuration template to be incorporated in the httpd.conf file:
1. First step is to create a custom template directory to add the template fragment:mkdir -p /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf
2. Now we are going to add our directive to a template which we call 25SetEnv:cat 'SetEnv STORE_BASE /home/e-smith/files/ibays/store' > /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/25SetEnv
3. The only thing that needs to be done is to regenerate the configuration file:expand-template /etc/httpd/conf/httpd.conf
4. Make sure that our settinfgs are in the configuration file:grep 'SetEnv STORE_BASE' /etc/httpd/conf/httpd.conf
which should output the text we entered in quotes atr step 2.
5. and restart the Apache webserver:service httpd-e-smith restart
You do not need the lines in your startup script anymore. This way changes can be portable over backups and upgrades.
-
Hi cactus,
I tried what you suggested and it worked great!! :shock:
Thank you very much for your help cactus you are the best!!
-
Thank you very much for your help cactus you are the best!!
Thanks very much... if you feel this way please hit the good advice button!
-
As you wish .... thanks again