How to set a cmd-line Environment Variable using services

Problems with the Windows version of XAMPP, questions, comments, and anything related.

How to set a cmd-line Environment Variable using services

Postby TomXampp » 22. March 2017 16:37

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]
TomXampp
 
Posts: 59
Joined: 12. March 2015 03:58
Operating System: Windows 8.1

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

Postby Nobbie » 22. March 2017 19:47

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.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

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

Postby TomXampp » 22. March 2017 19:53

@Nobbie You're unaware of this feature of HTTPD.EXE. See: https://httpd.apache.org/docs/2.4/mod/core.html#ifdefine
TomXampp
 
Posts: 59
Joined: 12. March 2015 03:58
Operating System: Windows 8.1

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

Postby Nobbie » 22. March 2017 19:57

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.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

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

Postby TomXampp » 22. March 2017 20:03

@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.
TomXampp
 
Posts: 59
Joined: 12. March 2015 03:58
Operating System: Windows 8.1

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

Postby TomXampp » 22. March 2017 20:07

@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.
TomXampp
 
Posts: 59
Joined: 12. March 2015 03:58
Operating System: Windows 8.1

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

Postby TomXampp » 22. March 2017 20:23

@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.
TomXampp
 
Posts: 59
Joined: 12. March 2015 03:58
Operating System: Windows 8.1

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

Postby Altrea » 22. March 2017 20:28

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.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

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

Postby TomXampp » 22. March 2017 20:38

Thanks, Altrea.
TomXampp
 
Posts: 59
Joined: 12. March 2015 03:58
Operating System: Windows 8.1


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 160 guests