Page 1 of 1

How to set a cmd-line Environment Variable using services

PostPosted: 22. March 2017 16:37
by TomXampp
I'm using XAMPP 7.1.1 on Windows 8.1 Pro. I am using the Xampp Control Panel and starting Apache and MySql as services. I want to set an environment variable, like this:

Code: Select all
httpd.exe -D MyEnvironmentVar


...so that I can reference it in my .htaccess file, like this:

Code: Select all
<IfDefine MyEnvironmentVar>
...
</IfDefine>

What file do I edit to add this environment variable, and how do I edit it?

Many thanks!

[EDIT by Altrea: moved to the english section of this board]

Re: How to set a cmd-line Environment Variable using service

PostPosted: 22. March 2017 19:47
by Nobbie
Environment Variables are a feature of the Operating System (Windows), not of Xampp. If you dont know how to setup your environment, proceed to a Microsoft Windows Forum and ask there. There is no "Xampp Tool" or "Xampp File" to setup the environment. That is done in your Windows Setup.

Re: How to set a cmd-line Environment Variable using service

PostPosted: 22. March 2017 19:53
by TomXampp
@Nobbie You're unaware of this feature of HTTPD.EXE. See: https://httpd.apache.org/docs/2.4/mod/core.html#ifdefine

Re: How to set a cmd-line Environment Variable using service

PostPosted: 22. March 2017 19:57
by Nobbie
TomXampp wrote:@Nobbie You're unaware of this feature of HTTPD.EXE. See: https://httpd.apache.org/docs/2.4/mod/core.html#ifdefine


No, you are unaware of the difference between EVALUATING a variable and SETTING a variable. Just the reason why you are asking here (in the wrong board). And: it seems you (wrongly) think, that these variables are Environment Variables. As far as I can see, there is only one way to setup that variable and thats the way you already mentioned (httpd.exe -Dxxxxxx). There is no other way to define variables for Apache configuration.

Re: How to set a cmd-line Environment Variable using service

PostPosted: 22. March 2017 20:03
by TomXampp
@Nobbie, click on the link and read the spec. If you execute httpd.exe with the -D parameter, you will then have access to the settings/directives that you've specified in your .htaccess file. Read it. It states that executing httpd.exe with these -D switches:

Code: Select all
httpd -DReverseProxy -DUseCache -DMemCache ...


...will allow you to check for the presence of those "directives" in your .htaccess file, like this:

Code: Select all
<IfDefine ReverseProxy>
  LoadModule proxy_module   modules/mod_proxy.so
  LoadModule proxy_http_module   modules/mod_proxy_http.so
  <IfDefine UseCache>
    LoadModule cache_module   modules/mod_cache.so
    <IfDefine MemCache>
      LoadModule mem_cache_module   modules/mod_mem_cache.so
    </IfDefine>
    <IfDefine !MemCache>
      LoadModule cache_disk_module   modules/mod_cache_disk.so
    </IfDefine>
  </IfDefine>
</IfDefine>


Click on the spec and read it. This is discussed elsewhere online. The question is how to use it when using the XAMPP Control Panel.

Re: How to set a cmd-line Environment Variable using service

PostPosted: 22. March 2017 20:07
by TomXampp
@Nobbie For clarification, I'm not disagreeing with you when you state "As far as I can see, there is only one way to setup that variable and thats the way you already mentioned (httpd.exe -Dxxxxxx). There is no other way to define variables for Apache configuration."

The question is how to do this when using the XAMPP Control Panel.

That is my question, pure and simple.

Re: How to set a cmd-line Environment Variable using service

PostPosted: 22. March 2017 20:23
by TomXampp
@Nobbie Perhaps my post title is misworded. It should read "How to set directives when using Xampp Control Panel." They are, in fact, set normally when executing HTTPD.EXE in a CMD session. My guess is that my post title confused you. Sorry about that.

Re: How to set a cmd-line Environment Variable using service

PostPosted: 22. March 2017 20:28
by Altrea
AFAIK there is no documentated way to add Parameters to the start commands which are used by the control panel.
The xampp-control.ini file has a sections for the [BinaryNames], but i don't know if the start commands are using these.

The only ways which surely should work are don't using the control panel to start the components or to edit and recompile the sources of the control panel.

Re: How to set a cmd-line Environment Variable using service

PostPosted: 22. March 2017 20:38
by TomXampp
Thanks, Altrea.