2

I have very simple task to do, since i am not expert in this field i am asking for a help.

Right now i am trying to run apache on my mac, i have windows working script and i need basically to do the same thing on mac.

Since mac comes with apache out of the box i realised i don't need to download it, like i had to do on windows machine.

Script i was running on my windows machine looks like this:

C:\dev\apache\Apache2\bin\httpd -f C:\dev\jboss-4.2.2.GA\server\myapp\httpd\conf\httpd.conf -D ssl
pause

And basically to start apache on my mac i simply have to do this:

sudo apachectl start

So i assume that windows script is basically starting apache with that httpd.conf from jboss location.

I am wondering how i can do the same on my mac, i already have identical jboss-4.2.2.GA folder.

My first assumption is that i can manually edit default mac httpd.conf which is located here: /etc/apache2/httpd.conf with this file: C:\dev\jboss-4.2.2.GA\server\myapp\httpd\conf\httpd.conf, but i am a bit confused since i don't know what to do with this -D ssl.

I would appreciate if someone could explain me what is best way to deal with this on mac.

1

1 Answer 1

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .