From the Apache documentation page for httpd
:
-D parameter
Sets a configuration parameter which can be used with <IfDefine>
sections in the configuration files to conditionally skip or process commands at server startup and restart. Also can be used to set certain less-common startup parameters including -DNO_DETACH
(prevent the parent from forking) and -DFOREGROUND
(prevent the parent from calling setsid()
et al).
From the Apache documentation page for <IfDefine>
:
The <IfDefine test>...</IfDefine>
section is used to mark directives that are conditional. The directives within an <IfDefine>
section are only processed if the test is true. If test is false, everything between the start and end markers is ignored.
The test in the <IfDefine>
section directive can be one of two forms:
- parameter-name
- !parameter-name
In the former case, the directives between the start and end markers are only processed if the parameter named parameter-name is defined. The second format reverses the test, and only processes the directives if parameter-name is not defined.
The parameter-name argument is a define as given on the httpd
command line via -Dparameter
at the time the server was started or by the Define
directive.
In short, this means that for your Windows startup script the argument -D ssl
defines a parameter named ssl, which enables any options in your httpd.conf enclosed by <IfDefine ssl>
sections.
However, for your macOS startup command you're using apachectl start
, which doesn't support passing additional arguments such as -D
. Therefore the ssl parameter cannot be set when running that command.
This means that on your Mac, any options in your httpd.conf that are enclosed by an <IfDefine ssl>
section will not be enabled. If you've copied over your Windows httpd.conf file then it's probably safe to assume that the options to enable SSL will be disabled because of this.
The solution is to go through your Windows httpd.conf and search for the string <IfDefine ssl>
. You'll want to comment that out as well as its corresponding </IfDefine>
. It might appear multiple times. This will make sure that the options enclosed in that section are always enabled, since I assume you want SSL to be on every time you start Apache.
You also might find sections with <IfDefine !ssl>
. On Windows these sections would be disabled when the startup command had the argument -D ssl
. However on your Mac -D ssl
is not being passed, meaning these sections will be turned on even though we don't want them to be. Comment out this entire section since we want it not to be run.
You should start with an httpd.conf that looks something like this:
...
<IfDefine ssl>
OptionOne yes
OptionTwo no
<Subsection>
OptionThree yes
</Subsection>
</IfDefine>
<IfDefine !ssl>
OptionOne no
OptionTwo yes
</IfDefine>
...
And end up with this:
...
#<IfDefine ssl>
OptionOne yes
OptionTwo no
<Subsection>
OptionThree yes
</Subsection>
#</IfDefine>
#<IfDefine !ssl>
# OptionOne no
# OptionTwo yes
#</IfDefine>
...
Then you can copy your Windows httpd.conf over to your Mac's httpd.conf. Be sure to save a copy of the original! Now running sudo apachectl start
will function the same as your Windows command.